I am prototyping a build of 2008 R2 on Azure. I have working code to deploy the VM, retrieve the x509 certificate, and establish WinRM access to remote Powershell on the deploye
I've run into this as well and I'm pretty sure the problem is that wusa cannot be invoked remotely:
KB: Windows Update Standalone Installer (WUSA) returns 0x5 ERROR_ACCESS_DENIED when deploying .msu files through WinRM and Windows Remote Shell
The problem stems from the fact that the .NET 4.0 installer has a couple of msu updates that it wants to apply. Because wusa can't be run from a remote command, the whole shebang fails.
EDIT: I did some digging and found an undocumented flag in ParamaterInfo.xml - the SkipMSUInstall flag will bypass the msu installs, negating the wusa calls, resulting in a successful install. I've just run through this on a few hundred servers and it works great. Our security policies don't allow for CredSSP to be used, so I'm copying the install files locally on each server, then using Invoke-Command and Start-Process to run the installs.
Modified powershell snippet below:
$servers = get-Content c:\temp\serverlist.txt
foreach ($server in $servers) {
$session = New-PSSession -ComputerName $server -Credential $credential
Invoke-Command -session $session -asJob -scriptBlock {
Start-Process "C:\Temp\dotNetFx40_Full_x86_x64\setup.exe" -ArgumentList "/passive /norestart /SkipMSUInstall" -Wait -Passthru
}
}