Skip to content

Instantly share code, notes, and snippets.

@Santaro255
Created March 12, 2019 13:54
Show Gist options
  • Save Santaro255/73626bf4bbb8838338150fba120d2fe5 to your computer and use it in GitHub Desktop.
Save Santaro255/73626bf4bbb8838338150fba120d2fe5 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