Skip to content

Instantly share code, notes, and snippets.

@erdtsieck
Created January 6, 2016 13:37
Show Gist options
  • Save erdtsieck/1c8b08de99a9012f204d to your computer and use it in GitHub Desktop.
Save erdtsieck/1c8b08de99a9012f204d to your computer and use it in GitHub Desktop.
Run a command on an external PC via Powershell
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