Created
April 21, 2017 07:33
-
-
Save andykuszyk/1c8d0f1cdbedb72e970056d0c6660996 to your computer and use it in GitHub Desktop.
Remote powershell
This file contains hidden or 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
$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