Files
runner-images/images/win/scripts/Installers/Validate-AzureModules.ps1
T

44 lines
1.3 KiB
PowerShell
Raw Normal View History

################################################################################
## File: Validate-AzureModules.ps1
## Desc: Validate Azure PowerShell modules
################################################################################
2020-07-01 15:16:01 +03:00
$ErrorActionPreference = "Stop"
2020-02-25 19:20:15 +03:00
2020-07-01 15:16:01 +03:00
$modulesRootPath = $env:PSMODULES_ROOT_FOLDER
# Get modules content from toolset
$modules = (Get-ToolsetContent).azureModules
foreach ($module in $modules)
{
foreach ($version in $module.versions)
2020-02-25 19:20:15 +03:00
{
2020-07-01 15:16:01 +03:00
$moduleName = $module.name
$modulePath = Join-Path -Path $modulesRootPath -ChildPath "$($module.name)_${version}"
Write-Host "Trying to import ${moduleName}_${version}..."
$testJob = Start-Job -ScriptBlock {
param (
$modulePath,
$moduleName
)
2020-02-25 19:20:15 +03:00
2020-02-27 12:58:03 +03:00
$env:PsModulePath = "$modulePath;$env:PsModulePath"
Import-Module -Name $moduleName
Get-Module -Name $moduleName
2020-07-01 15:16:01 +03:00
2020-02-27 12:58:03 +03:00
} -ArgumentList $modulePath, $moduleName
2020-07-01 15:16:01 +03:00
$isError = $testJob | Wait-Job | Foreach-Object ChildJobs | Where-Object { $_.Error }
if ($isError)
2020-02-25 19:20:15 +03:00
{
2020-07-01 15:16:01 +03:00
Write-Host "Required ${moduleName} module ${version} version is not present"
2020-02-25 19:20:15 +03:00
exit 1
}
2020-07-01 15:16:01 +03:00
$testJob | Receive-Job | Select-Object Name,Version,Path
Remove-Job $testJob
2020-02-25 19:20:15 +03:00
}
2020-07-01 15:16:01 +03:00
}