Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mikebranstein/394b05a27df0bd16861d946e0a716be7 to your computer and use it in GitHub Desktop.
Save mikebranstein/394b05a27df0bd16861d946e0a716be7 to your computer and use it in GitHub Desktop.
Establish a remote PowerShell session
$username = "administrator"
$password = "your-super-secret-password"
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force
$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $username, $securePassword
$pstimeout = New-PSSessionoption -OperationTimeout (1000*60*5)
$session = New-PSSession -computer $ipAddress -Credential $cred -ErrorAction Stop -SessionOption $pstimeout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment