Error during unattended Azure PowerShell installation

When I run a PowerShell script to silently install Azure PowerShell, it throws this exception:

Throwing "DownloadInstallerFile" exception with argument "2": "The InstallerContext passed to this method requires a non-Null InstallerFile." Line: 18 char: 5

Script follows:

[reflection.assembly]::LoadWithPartialName("Microsoft.Web.PlatformInstaller") | Out-Null

$ProductManager = New-Object Microsoft.Web.PlatformInstaller.ProductManager
$ProductManager.Load()
$product = $ProductManager.Products | Where { $_.ProductId -eq "WindowsAzurePowerShell" }

$InstallManager = New-Object Microsoft.Web.PlatformInstaller.InstallManager

$Language = $ProductManager.GetLanguage("en")
$installertouse = $product.GetInstaller($Language)

$installer = New-Object 'System.Collections.Generic.List[Microsoft.Web.PlatformInstaller.Installer]'
$installer.Add($installertouse)
$InstallManager.Load($installer)

$failureReason=$null
foreach ($installerContext in $InstallManager.InstallerContexts) {
    $InstallManager.DownloadInstallerFile($installerContext, [ref]$failureReason)
}
$InstallManager.StartInstallation()

      

How can I fix this?

+3


source to share





All Articles