Friday, February 22, 2013

Running PowerShell using PsExec

PsExec is used to run commands remotely on a machine.
I was trying to execute a PowerShell file remote using PsExec but the command would just hang.
Below is the command:

PsExec.exe \\MachineName powershell -File "FileName.ps1"

The fix was to run the command in an interactive mode by passing -i agrument to PsExec.
Here it is:

PsExec.exe -i \\MachineName powershell -File "FileName.ps1"

Sweet, the command ran fine this time!

3 comments:

  1. Thanks for that, That's exactly what I was experiencing - problem solved

    ReplyDelete