mirror of
https://github.com/actions/runner-images-sangeeth.git
synced 2025-12-20 06:29:50 +00:00
Revert "Another mop up commit to add missing changes from the last mop-up."
This reverts commit 1dcd276b1e.
This commit is contained in:
@@ -1,83 +1,83 @@
|
||||
function Install-MSI
|
||||
{
|
||||
Param
|
||||
(
|
||||
[String]$MsiUrl,
|
||||
[String]$MsiName
|
||||
)
|
||||
|
||||
$exitCode = -1
|
||||
|
||||
try
|
||||
{
|
||||
Write-Host "Downloading $MsiName..."
|
||||
$FilePath = "${env:Temp}\$MsiName"
|
||||
|
||||
Invoke-WebRequest -Uri $MsiUrl -OutFile $FilePath
|
||||
|
||||
$Arguments = ('/i', $FilePath, '/QN', '/norestart' )
|
||||
|
||||
Write-Host "Starting Install $MsiName..."
|
||||
$process = Start-Process -FilePath msiexec.exe -ArgumentList $Arguments -Wait -PassThru
|
||||
$exitCode = $process.ExitCode
|
||||
|
||||
if ($exitCode -eq 0 -or $exitCode -eq 3010)
|
||||
{
|
||||
Write-Host -Object 'Installation successful'
|
||||
return $exitCode
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Host -Object "Non zero exit code returned by the installation process : $exitCode."
|
||||
exit $exitCode
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
Write-Host -Object "Failed to install the MSI $MsiName"
|
||||
Write-Host -Object $_.Exception.Message
|
||||
exit -1
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function Install-EXE
|
||||
{
|
||||
Param
|
||||
(
|
||||
[String]$Url,
|
||||
[String]$Name,
|
||||
[String[]]$ArgumentList
|
||||
)
|
||||
|
||||
$exitCode = -1
|
||||
|
||||
try
|
||||
{
|
||||
Write-Host "Downloading $Name..."
|
||||
$FilePath = "${env:Temp}\$Name"
|
||||
|
||||
Invoke-WebRequest -Uri $Url -OutFile $FilePath
|
||||
|
||||
Write-Host "Starting Install $Name..."
|
||||
$process = Start-Process -FilePath $FilePath -ArgumentList $ArgumentList -Wait -PassThru
|
||||
$exitCode = $process.ExitCode
|
||||
|
||||
if ($exitCode -eq 0 -or $exitCode -eq 3010)
|
||||
{
|
||||
Write-Host -Object 'Installation successful'
|
||||
return $exitCode
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Host -Object "Non zero exit code returned by the installation process : $exitCode."
|
||||
return $exitCode
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
Write-Host -Object "Failed to install the Executable $Name"
|
||||
Write-Host -Object $_.Exception.Message
|
||||
return -1
|
||||
}
|
||||
}
|
||||
function Install-MSI
|
||||
{
|
||||
Param
|
||||
(
|
||||
[String]$MsiUrl,
|
||||
[String]$MsiName
|
||||
)
|
||||
|
||||
$exitCode = -1
|
||||
|
||||
try
|
||||
{
|
||||
Write-Host "Downloading $MsiName..."
|
||||
$FilePath = "${env:Temp}\$MsiName"
|
||||
|
||||
Invoke-WebRequest -Uri $MsiUrl -OutFile $FilePath
|
||||
|
||||
$Arguments = ('/i', $FilePath, '/QN', '/norestart' )
|
||||
|
||||
Write-Host "Starting Install $MsiName..."
|
||||
$process = Start-Process -FilePath msiexec.exe -ArgumentList $Arguments -Wait -PassThru
|
||||
$exitCode = $process.ExitCode
|
||||
|
||||
if ($exitCode -eq 0 -or $exitCode -eq 3010)
|
||||
{
|
||||
Write-Host -Object 'Installation successful'
|
||||
return $exitCode
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Host -Object "Non zero exit code returned by the installation process : $exitCode."
|
||||
exit $exitCode
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
Write-Host -Object "Failed to install the MSI $MsiName"
|
||||
Write-Host -Object $_.Exception.Message
|
||||
exit -1
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function Install-EXE
|
||||
{
|
||||
Param
|
||||
(
|
||||
[String]$Url,
|
||||
[String]$Name,
|
||||
[String[]]$ArgumentList
|
||||
)
|
||||
|
||||
$exitCode = -1
|
||||
|
||||
try
|
||||
{
|
||||
Write-Host "Downloading $Name..."
|
||||
$FilePath = "${env:Temp}\$Name"
|
||||
|
||||
Invoke-WebRequest -Uri $Url -OutFile $FilePath
|
||||
|
||||
Write-Host "Starting Install $Name..."
|
||||
$process = Start-Process -FilePath $FilePath -ArgumentList $ArgumentList -Wait -PassThru
|
||||
$exitCode = $process.ExitCode
|
||||
|
||||
if ($exitCode -eq 0 -or $exitCode -eq 3010)
|
||||
{
|
||||
Write-Host -Object 'Installation successful'
|
||||
return $exitCode
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Host -Object "Non zero exit code returned by the installation process : $exitCode."
|
||||
return $exitCode
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
Write-Host -Object "Failed to install the Executable $Name"
|
||||
Write-Host -Object $_.Exception.Message
|
||||
return -1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
function Add-ContentToMarkdown {
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
$Content = ""
|
||||
)
|
||||
|
||||
Add-Content 'C:\InstalledSoftware.md' $Content
|
||||
}
|
||||
|
||||
|
||||
function Add-SoftwareDetailsToMarkdown {
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
$SoftwareName = "",
|
||||
$DescriptionMarkdown = ""
|
||||
)
|
||||
|
||||
$Content = @"
|
||||
|
||||
## $SoftwareName
|
||||
|
||||
$DescriptionMarkdown
|
||||
"@
|
||||
Add-ContentToMarkdown -Content $Content
|
||||
}
|
||||
function Add-ContentToMarkdown {
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
$Content = ""
|
||||
)
|
||||
|
||||
Add-Content 'C:\InstalledSoftware.md' $Content
|
||||
}
|
||||
|
||||
|
||||
function Add-SoftwareDetailsToMarkdown {
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
$SoftwareName = "",
|
||||
$DescriptionMarkdown = ""
|
||||
)
|
||||
|
||||
$Content = @"
|
||||
|
||||
## $SoftwareName
|
||||
|
||||
$DescriptionMarkdown
|
||||
"@
|
||||
Add-ContentToMarkdown -Content $Content
|
||||
}
|
||||
|
||||
@@ -1,68 +1,68 @@
|
||||
function Test-MachinePath{
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[string]$PathItem
|
||||
)
|
||||
|
||||
$currentPath = Get-MachinePath
|
||||
|
||||
$pathItems = $currentPath.Split(';')
|
||||
|
||||
if($pathItems.Contains($PathItem))
|
||||
{
|
||||
return $true
|
||||
}
|
||||
else
|
||||
{
|
||||
return $false
|
||||
}
|
||||
}
|
||||
|
||||
function Set-MachinePath{
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[string]$NewPath
|
||||
)
|
||||
Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name Path -Value $NewPath
|
||||
return $NewPath
|
||||
}
|
||||
|
||||
function Add-MachinePathItem
|
||||
{
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[string]$PathItem
|
||||
)
|
||||
|
||||
$currentPath = Get-MachinePath
|
||||
$newPath = $PathItem + ';' + $currentPath
|
||||
return Set-MachinePath -NewPath $newPath
|
||||
}
|
||||
|
||||
function Get-MachinePath{
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
|
||||
)
|
||||
$currentPath = (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH).Path
|
||||
return $currentPath
|
||||
}
|
||||
|
||||
function Get-SystemVariable{
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[string]$SystemVariable
|
||||
)
|
||||
$currentPath = (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name $SystemVariable).$SystemVariable
|
||||
return $currentPath
|
||||
}
|
||||
|
||||
function Set-SystemVariable{
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[string]$SystemVariable,
|
||||
[string]$Value
|
||||
)
|
||||
Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name $SystemVariable -Value $Value
|
||||
return $Value
|
||||
}
|
||||
function Test-MachinePath{
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[string]$PathItem
|
||||
)
|
||||
|
||||
$currentPath = Get-MachinePath
|
||||
|
||||
$pathItems = $currentPath.Split(';')
|
||||
|
||||
if($pathItems.Contains($PathItem))
|
||||
{
|
||||
return $true
|
||||
}
|
||||
else
|
||||
{
|
||||
return $false
|
||||
}
|
||||
}
|
||||
|
||||
function Set-MachinePath{
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[string]$NewPath
|
||||
)
|
||||
Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name Path -Value $NewPath
|
||||
return $NewPath
|
||||
}
|
||||
|
||||
function Add-MachinePathItem
|
||||
{
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[string]$PathItem
|
||||
)
|
||||
|
||||
$currentPath = Get-MachinePath
|
||||
$newPath = $PathItem + ';' + $currentPath
|
||||
return Set-MachinePath -NewPath $newPath
|
||||
}
|
||||
|
||||
function Get-MachinePath{
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
|
||||
)
|
||||
$currentPath = (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH).Path
|
||||
return $currentPath
|
||||
}
|
||||
|
||||
function Get-SystemVariable{
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[string]$SystemVariable
|
||||
)
|
||||
$currentPath = (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name $SystemVariable).$SystemVariable
|
||||
return $currentPath
|
||||
}
|
||||
|
||||
function Set-SystemVariable{
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[string]$SystemVariable,
|
||||
[string]$Value
|
||||
)
|
||||
Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name $SystemVariable -Value $Value
|
||||
return $Value
|
||||
}
|
||||
@@ -1,34 +1,34 @@
|
||||
. $PSScriptRoot\..\PathHelpers.ps1
|
||||
|
||||
Describe 'Test-MachinePath Tests' {
|
||||
Mock Get-MachinePath {return "C:\foo;C:\bar"}
|
||||
It 'Path contains item' {
|
||||
Test-MachinePath -PathItem "C:\foo" | Should Be $true
|
||||
}
|
||||
It 'Path does not containe item' {
|
||||
Test-MachinePath -PathItem "C:\baz" | Should Be $false
|
||||
}
|
||||
}
|
||||
|
||||
Describe 'Set-MachinePath Tests' {
|
||||
Mock Get-MachinePath {return "C:\foo;C:\bar"}
|
||||
Mock Set-ItemProperty {return}
|
||||
It 'Set-MachinePath should return new path' {
|
||||
Set-MachinePath -NewPath "C:\baz" | Should Be "C:\baz"
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Add-MachinePathItem Tests"{
|
||||
Mock Get-MachinePath {return "C:\foo;C:\bar"}
|
||||
Mock Set-ItemProperty {return}
|
||||
It 'Add-MachinePathItem should return complete path' {
|
||||
Add-MachinePathItem -PathItem 'C:\baz' | Should Be 'C:\baz;C:\foo;C:\bar'
|
||||
}
|
||||
}
|
||||
|
||||
Describe 'Set-SystemVariable Tests' {
|
||||
Mock Set-ItemProperty {return}
|
||||
It 'Set-SystemVariable should return new path' {
|
||||
Set-SystemVariable -SystemVariable "NewPathVar" -Value "C:\baz" | Should Be "C:\baz"
|
||||
}
|
||||
}
|
||||
. $PSScriptRoot\..\PathHelpers.ps1
|
||||
|
||||
Describe 'Test-MachinePath Tests' {
|
||||
Mock Get-MachinePath {return "C:\foo;C:\bar"}
|
||||
It 'Path contains item' {
|
||||
Test-MachinePath -PathItem "C:\foo" | Should Be $true
|
||||
}
|
||||
It 'Path does not containe item' {
|
||||
Test-MachinePath -PathItem "C:\baz" | Should Be $false
|
||||
}
|
||||
}
|
||||
|
||||
Describe 'Set-MachinePath Tests' {
|
||||
Mock Get-MachinePath {return "C:\foo;C:\bar"}
|
||||
Mock Set-ItemProperty {return}
|
||||
It 'Set-MachinePath should return new path' {
|
||||
Set-MachinePath -NewPath "C:\baz" | Should Be "C:\baz"
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Add-MachinePathItem Tests"{
|
||||
Mock Get-MachinePath {return "C:\foo;C:\bar"}
|
||||
Mock Set-ItemProperty {return}
|
||||
It 'Add-MachinePathItem should return complete path' {
|
||||
Add-MachinePathItem -PathItem 'C:\baz' | Should Be 'C:\baz;C:\foo;C:\bar'
|
||||
}
|
||||
}
|
||||
|
||||
Describe 'Set-SystemVariable Tests' {
|
||||
Mock Set-ItemProperty {return}
|
||||
It 'Set-SystemVariable should return new path' {
|
||||
Set-SystemVariable -SystemVariable "NewPathVar" -Value "C:\baz" | Should Be "C:\baz"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user