Skip to content

Instantly share code, notes, and snippets.

@zdi-team
Created August 16, 2021 14:41
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 zdi-team/a2eb014d248e4e54a2ab4ba4ae3ac3cf to your computer and use it in GitHub Desktop.
Save zdi-team/a2eb014d248e4e54a2ab4ba4ae3ac3cf to your computer and use it in GitHub Desktop.
$uri = 'http://127.0.0.1:8000/PowerShell/'
$username = 'whatever' # unimportant
$password = 'whatever' # unimportant
$secure = ConvertTo-SecureString $password -AsPlainText -Force
$creds = New-Object System.Management.Automation.PSCredential -ArgumentList ($username, $secure)
$option = New-PSSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck
$params = @{
ConfigurationName = "Microsoft.Exchange"
Authentication = "Basic"
ConnectionUri = $uri
Credential = $creds
SessionOption = $option
AllowRedirection = $ture
}
$session = New-PSSession @params
Invoke-Command -Session $session -ScriptBlock {
# PowerShell commands to execute...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment