Skip to content

Instantly share code, notes, and snippets.

@andykuszyk
Created April 21, 2017 07:33
Show Gist options
  • Save andykuszyk/1c8d0f1cdbedb72e970056d0c6660996 to your computer and use it in GitHub Desktop.
Save andykuszyk/1c8d0f1cdbedb72e970056d0c6660996 to your computer and use it in GitHub Desktop.
Remote powershell
$serverAddress = "1.1.1.1"
$userName = "user"
$securePassword = ConvertTo-SecureString -AsPlainText -Force -String "password"
$credentials = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $userName,$securePassword
$session = New-PSSession -ComputerName $serverAddress -Credential $credentials
Invoke-Command -Session $session -ScriptBlock {
Write-Host "hello world"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment