How can I remotely, programmatically install .NET 4 client on an Azure VM?

前端 未结 1 1816
广开言路
广开言路 2021-01-24 09:38

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

相关标签:
1条回答
  • 2021-01-24 10:22

    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
        }
      }
    
    0 讨论(0)
提交回复
热议问题