Skip to content

Instantly share code, notes, and snippets.

@jaymecd
Created October 16, 2019 08:55
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 jaymecd/fe1a10e0a4b319425bffe34189b5dd99 to your computer and use it in GitHub Desktop.
Save jaymecd/fe1a10e0a4b319425bffe34189b5dd99 to your computer and use it in GitHub Desktop.
Powershell: invoke command via winrm (NTLM over HTTPS)
# TEST WinRM connect
$targetHost = 'localhost'
$username = 'Administrator'
$password = 'PASSWORD'
$secret = ConvertTo-SecureString -String $password -AsPlainText -Force
$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $username, $secret
$option = New-PSSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck
Invoke-Command -ComputerName $targetHost -UseSSL -Authentication Negotiate -SessionOption $option -credential $cred -ScriptBlock { Get-ChildItem C:\ }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment