Skip to content

Instantly share code, notes, and snippets.

@marckean
Created April 25, 2018 01:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marckean/b1418887d7e6c20c47fae1c0f8fced59 to your computer and use it in GitHub Desktop.
Save marckean/b1418887d7e6c20c47fae1c0f8fced59 to your computer and use it in GitHub Desktop.
$RemoteMachines = '1598.domain.com', '1599.domain.com'
$adminname = 'user.name'
$adminpassword = 'YourPassword'
$password = ConvertTo-SecureString $adminpassword -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential (".\$adminname", $password)
$SessionOptions = New-PSSessionOption –SkipCACheck –SkipCNCheck –SkipRevocationCheck
$PSSession = New-PSSession -ComputerName $RemoteMachines -Port 5986 -UseSSL -Authentication Credssp -Credential $cred -SessionOption $SessionOptions
# Do stuff
Invoke-Command -Session $PSSession -ScriptBlock {
gci C:
whoami
}
Get-PSSession | Remove-PSSession
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment