Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save vincent1890/b1563eacd7e760b6c45d94026b104ba6 to your computer and use it in GitHub Desktop.
Save vincent1890/b1563eacd7e760b6c45d94026b104ba6 to your computer and use it in GitHub Desktop.
create\remove PSSession to Exchange server
$q=Read-Host -Prompt "connect\disconnect"
switch ($q) {
{$q -eq "connect"} {$fqdn=Read-Host -Prompt "Enter FQDN"
$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://"$fqdn"/PowerShell/ -Authentication Kerberos -Credential $UserCredential
Import-PSSession $Session -DisableNameChecking}
{$q -eq "disconnect"} {Remove-PSSession $Session}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment