packer-plugin-windows-update
packer-plugin-windows-update copied to clipboard
Doesn't work with environment_vars
We need to access a proxy server to get out for windows updates. Normally we use environment_vars to get powershell and windows_shell provisioners to work with our proxies.
Could we add something to this that allowed the use of environment_vars to work with proxies?
Can you provide an example on what variables are needed to configure windows updates for that?
Apologies for jumping on this, but this requirement would work for me. Example,
"environment_vars": "http_proxy=x.x.x.x:8080", "https_proxy=x.x.x.x:8080"
Hello, I would also need this feature. In order to download Windows Updates I have to go through a proxy. The quick and dirty solution would be to hardcode it into the windows-updates.ps1 using System.Net.WebProxy.
But indeed, having the possibility to set a proxy variable in the provisionner declaration would be great.
To add proxy config ps1, add ebproxy properties to variables $UpdateSession. :
while ($true) {
try {
$updateSession = New-Object -ComObject 'Microsoft.Update.Session'
$updateSession.ClientApplicationID = 'packer-windows-update'
$UpdateSession.WebProxy.Address = $proxy
$UpdateSession.WebProxy.AutoDetect = $False
$updateSearcher = $updateSession.CreateUpdateSearcher()
$searchResult = $updateSearcher.Search($SearchCriteria)
if ($searchResult.ResultCode -eq 2) {
break
}
$searchStatus = LookupOperationResultCode($searchResult.ResultCode)
} catch {
$searchStatus = $_.ToString()
}
Write-Output "Search for Windows updates failed with '$searchStatus'. Retrying..."
Start-Sleep -Seconds 5
}
Hi everyone, we really need this feature of configuring a proxy. Can you please add this to the next release? Thanks a lot!