Created
October 16, 2019 08:55
-
-
Save jaymecd/fe1a10e0a4b319425bffe34189b5dd99 to your computer and use it in GitHub Desktop.
Powershell: invoke command via winrm (NTLM over HTTPS)
This file contains 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
# 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