How to remote execute an ELEVATED remote script in PowerShell
elevated-privileges, powershell, powershell-2.0, powershell-remoting
Solution
Do you try to change `remoteDeploy.ps1` to start CMD.EXE with elevated rights :
cd D:\Builds\build5
start-process CMD.EXE -verb runas -argumentlist "-C",".\Deploy.bat"
Problem
I have two servers: - serverA (windows 2003 server) - serverB (windows 7) ServerA contains a folder with a batch file (deploy.bat) that needs to be executed from an elevated powershell prompt. In ServerA, if I run it from a normal prompt or powershell prompt it fails. If I run it from an elevated prompt it works. (run as administrator). The problem I have is when I try to execute batch file from serverB using a remote powershell execution. I am able to execute with this command: ``` Invoke-Command -computername serverA .\remotedeploy.ps1 ``` The content of remotedeploy.ps1 is: ``` cd D:\Builds\build5 .\Deploy.bat ``` I have looked a lot questions in stackoverflow about: - Execute a remote powershell (This works for me) - Execute a local powershell with elevated prompt (I can do it) This question is about both at the same time. So the exact question is: Is possible to execute an ELEVATED REMOTE script in PowerShell?