Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
$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