Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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
You can’t perform that action at this time.