4

I'm currently working on a Powershell script to run some Microsoft Hotfix installers remotely on several Windows Server 2008 R2 servers that I manage. Basically, the script copies all the appropriate files up to the server, and then runs the installer via Invoke-Command, like so:

function InstallCU {
    Write-Host "Installing June 2013 CU..."
    Invoke-Command -ComputerName $ServerName -ScriptBlock {
        Start-Process "c:\aaa\prjcusp2\ubersrvprj2010-kb2817530-fullfile-x64-glb.exe" -ArgumentList "/passive"
    }
}

If I run the "Start-Process" command locally on the server, the installer runs properly. However, when trying to run it remotely, nothing happens (actually, I can see the installer start up in Task Manager, but it closes a couple seconds later and doesn't run).

I've attempted giving the Invoke-Command -Credentials, I've turned off UAC on the server, and I've ensured that my WinRM settings (running 'winrm quickconfig' and setting TrustedHosts to *) are correct. I've also tried having the Invoke-Command script run a local Powershell script to run the installer and changing the Argument from '/passive' to 'quiet' (in case it can't remotely launch something that has a UI), but again, no dice.

Is there anything else I can try, or am I just not going to be able to do this?

Nick DeMayo
  • 287
  • 4
  • 14

1 Answers1

3

Well, I feel a little ashamed, but I figured out what I was doing wrong. Basically, I needed to add the -Wait param to the Start-Process cmdlet. Final code looks like this:

function InstallCU {
    Write-Host "Installing June 2013 CU..."
    Invoke-Command -ComputerName $ServerName -ScriptBlock {
        Start-Process "c:\aaa\prjcusp2\ubersrvprj2010-kb2817530-fullfile-x64-glb.exe" -ArgumentList "/passive" -Wait
    }
}
Nick DeMayo
  • 287
  • 4
  • 14
  • Glad you've resolved this. Please be sure to [mark your answer as accepted](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work) when you're able. – jscott Nov 04 '13 at 11:49