Created
January 6, 2016 13:37
-
-
Save erdtsieck/1c8b08de99a9012f204d to your computer and use it in GitHub Desktop.
Run a command on an external PC via Powershell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Invoke-Command -ComputerName \\remotemachine -ScriptBlock { & "PATH_TO_SCRIPT_OR_EXECUTABLE" } -credential (new-object -typename System.Management.Automation.PSCredential -argumentlist "remoteuser", (echo "remotepassword" | ConvertTo-Securestring -AsPlainText -Force)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment