Exchange Server Export Mailboxes of Disabled Users
I was asked the other day to get a list of all the mailboxes connected to users disabled on Active Directory. I fired up Powershell ISE, loaded the Active Directory module and the Exchange snap-ins and started to work on my script. First of all, I had to get a list of all the users in Active Directory that were disabled. This is very easy to implement using the Get-ADUser cmdlet and the Filter parameter. The company's Identity Management System though when disabling a user, it also moves the object to specific OU named "Disabled". To get those users I used the Get-ADUser cmdlet with the SearchBase and filter paramaters: 1 2 $users = Get-ADUser -SearchBase "OU=DISABLED, DC=LAB, DC=LOCAL" -Filter * -Properties * | Where-Object { $_ .enabled -eq $false } Just to make sure that I do not include any active users, I piped the output to a Where-Object cmdlet. Now that I have all the users I had to check if they had a mailbox. Since the