This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Deprovision help

I started a deprovision task but i need some components to configure I know the power shell task to get this done not sure how to call the attributes from a deprovision script.  I guess overall how would the community do it.

 

  • Backup mailbox to PST
  • setup out of office with mail access to a user in a virtual attribute
  • dump mailbox folder list to a Text file
  • Remove Skype licence from user on deprovision
  • disable Exchange inbox rules
  • clear mailbox rights

BACKUP MAILBOX TO PST
New-MailboxExportRequest -Mailbox $user -FilePath "\\SERVER\Deprovision\$($user)\PSTBackup.pst"

DUMP MAILBOX FOLDER LIST TO A TEXT FILE
Get-MailboxFolderStatistics -Identity $user | Select Name,FolderPath,FolderSize,FolderAndSubfolderSize | out-file "\\SERVER\Deprovision\$($user)\MailboxTree.txt"

REMOVE SKYPE LICENCE FROM USER ON DEPROVISION
Set-CsUser -Identity $user -Enabled $False
Disable-CsUser -Identity $user

LOG AND REMOVE MAILBOXRULES
Get-InboxRule –Mailbox $user | Select Name, Description | FL | out-file "\\SERVER\Deprovision\($user)\userrules.txt"
$currentinboxrules = Get-InboxRule -mailbox $user | select name,description
if ($currentinboxrules) {
foreach ($currentinboxrule in $currentinboxrules) {
remove-inboxrule -mailbox $user -Identity $currentinboxrule.name -confirm:$false -AlwaysDeleteOutlookRulesBlob
$currentinboxrule | FL | out-file "\\SERVER\Deprovision\($user)\userrules.txt" -append
}
}
else {
Add-Content "\\SERVER\Deprovision\($user)\userrules.txt" 'No Inbox Rules Detected for this Mailbox'
}

# OUT OF OFFICE - AUTOREPLY
$message = "$($user.firstname) $($user.lastname) is no longer with the company. For client related issues, please contact $($revieweruserinformation.firstname) $($revieweruserinformation.lastname) at $($revieweruserinformation.email)"
set-mailboxautoreplyconfiguration $user -autoreplystate enabled -externalaudience all -internalmessage $message -externalmessage $message
# OUT OF OFFICE - RULE
$message = "$($user.firstname) $($user.lastname) is no longer with the company. For client related issues, please contact $($revieweruserinformation.firstname) $($revieweruserinformation.lastname) at $($revieweruserinformation.email)"

  • I would recommend:
    1. Deprovision policy sets all AD attributes upon Deprovision which might trigger Exchange Cmdlets etc...
    2. AR policy marks account (VA_DEPROVISION) as terminated to be processed.
    3. Schedule task will to the "time-expensive" steps - copy to PST for example.

  • when writing the deprovision script how do you call the user account and is the below the sub you would use.

    Sub onDeprovision(Request)

    End Sub'