Advertisement
PureGremlin

Exchange remote no UI

Mar 15th, 2024 (edited)
1,017
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function Connect-LocalExchange { ;
  2. $exchangeserver = read-host -prompt "fqdn of server" ; while (!($test)) {if (test-connection -computername $exchangeserver -count 1 -ErrorAction SilentlyContinue) {$test = $true}  else {$exchangeserver = read-host -prompt "Connection test to $($exchangeserver) failed. Enter fqdn of server again"} } ;
  3. $user = read-host -prompt "enter your domain qualified user; i.e. domain\user" ;
  4. #$pass = write-host "Enter your password for $($user)" ; read-host -AsSecureString ;
  5. $tmp = read-host -prompt "Enter your password for $($user)" ; $pass = $tmp | ConvertTo-SecureString -AsPlainText -Force ; rv tmp ;
  6. $cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $user,$pass ;
  7. $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://$exchangeserver/PowerShell/ -Credential $cred ;
  8. Import-PSSession $Session ;
  9. };Connect-LocalExchange
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement