Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Connect-LocalExchange { ;
- $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"} } ;
- $user = read-host -prompt "enter your domain qualified user; i.e. domain\user" ;
- #$pass = write-host "Enter your password for $($user)" ; read-host -AsSecureString ;
- $tmp = read-host -prompt "Enter your password for $($user)" ; $pass = $tmp | ConvertTo-SecureString -AsPlainText -Force ; rv tmp ;
- $cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $user,$pass ;
- $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://$exchangeserver/PowerShell/ -Credential $cred ;
- Import-PSSession $Session ;
- };Connect-LocalExchange
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement