mirror of
https://github.com/actions/runner-images.git
synced 2025-12-14 13:17:54 +00:00
* first part * fix session manager plugin * rework AWS installation * azure cosmos db tests * azure devops cli * add azmodules test * put brackets * add root folder * remove validate aliyun * add azure modules * update modules test * docker, baze, dotnetsdk * DACFx * add azdevopscli * change to Should -BeTrue * nitpicks * remove extra * add azurecli * remove BeforeAll for DACFx * a bit of refactoring * fix templates * remove disk space validation * rename to powershell modules * fix templates
57 lines
1.9 KiB
PowerShell
57 lines
1.9 KiB
PowerShell
################################################################################
|
|
## File: Install-AzureModules.ps1
|
|
## Desc: Install Azure PowerShell modules
|
|
################################################################################
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
Set-PSRepository -InstallationPolicy Trusted -Name PSGallery
|
|
|
|
# The correct Modules need to be saved in C:\Modules
|
|
$installPSModulePath = $env:PSMODULES_ROOT_FOLDER
|
|
if (-not (Test-Path -LiteralPath $installPSModulePath))
|
|
{
|
|
Write-Host "Creating ${installPSModulePath} folder to store PowerShell Azure modules..."
|
|
$null = New-Item -Path $installPSModulePath -ItemType Directory
|
|
}
|
|
|
|
# Get modules content from toolset
|
|
$modules = (Get-ToolsetContent).azureModules
|
|
|
|
$psModuleMachinePath = ""
|
|
|
|
foreach ($module in $modules)
|
|
{
|
|
$moduleName = $module.name
|
|
|
|
Write-Host "Installing ${moduleName} to the ${installPSModulePath} path..."
|
|
foreach ($version in $module.versions)
|
|
{
|
|
$modulePath = Join-Path -Path $installPSModulePath -ChildPath "${moduleName}_${version}"
|
|
Write-Host " - $version [$modulePath]"
|
|
try
|
|
{
|
|
Save-Module -Path $modulePath -Name $moduleName -RequiredVersion $version -Force -ErrorAction Stop
|
|
}
|
|
catch
|
|
{
|
|
Write-Host "Error: $_"
|
|
exit 1
|
|
}
|
|
}
|
|
|
|
# Append default tool version to machine path
|
|
if ($null -ne $module.default)
|
|
{
|
|
$defaultVersion = $module.default
|
|
|
|
Write-Host "Use ${moduleName} ${defaultVersion} as default version..."
|
|
$psModuleMachinePath += "${installPSModulePath}\${moduleName}_${defaultVersion};"
|
|
}
|
|
}
|
|
|
|
# Add modules to the PSModulePath
|
|
$psModuleMachinePath += $env:PSModulePath
|
|
[Environment]::SetEnvironmentVariable("PSModulePath", $psModuleMachinePath, "Machine")
|
|
|
|
Invoke-PesterTests -TestFile "PowerShellModules" -TestName "AzureModules" |