Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Connect to exchange
- $UserCredential = Get-Credential
- $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://exchange.server.com/PowerShell/ -Authentication Kerberos -Credential $UserCredential
- import-PSSession $Session
- #Get Param from external command
- $Euser = $args[0]
- #format password to contain date task was run.
- #I will eventually write this to a log and append to it each run
- $SDate = (Get-Date).ToString("MMddyy")
- $PWD = "Term"+ $SDate
- #Start of actual tasks
- Set-CASMailbox -Identity $Euser -ActiveSyncEnabled $false
- Set-CASMailbox -Identity $Euser -OWAEnabled $false
- Set-CASMailbox -Identity $Euser -PopEnabled $false
- Set-CASMailbox -Identity $Euser -ImapEnabled $false
- Set-CASMailbox -Identity $Euser -MapiEnabled $false
- Set-AdaccountPassword -Identity $Euser -Reset -NewPassword (ConvertTo-SecureString -AsPlainText $PWD -Force)
- Disable-ADAccount $Euser
- #inform of completion
- write-host $Euser "has been deactivated in AD and Exchange. Password has been reset."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement