How do I run commands on a remote machine with admin privilege (example: running as Run as Administrator) using PowerShell.
So far I have tried
start-process powershell.exe -verb runas -argumentlists ".\test.ps1"
This is failing.
powershellremote-access
How do I run commands on a remote machine with admin privilege (example: running as Run as Administrator) using PowerShell.
So far I have tried
start-process powershell.exe -verb runas -argumentlists ".\test.ps1"
This is failing.
Best Answer
Executing a Remote Command
Use the Invoke-Command cmdlet to run a command on a remote machine. The syntax is as follows:
COMMAND is the command you want to run, COMPUTER is the remote machine’s hostname, and USERNAME is the username of the account under which you want to run the command. You will be prompted for the password.
Starting a Remote Session
Use the Enter-PSSession cmdlet to start a remote PowerShell session in which you can run multiple commands using the Session parameter of Invoke-Command:
Source: http://www.howtogeek.com/117192/how-to-run-powershell-commands-on-remote-computers/