Export and Disable Exchange Mailboxes With Specific Attributes Using PowerShell

I have been working on archiving and removing a a little over 3000 Exchange Mailboxes that had been sitting since my client's move to Google Apps. Obviously, I didn't want to manually go through and export and disable all of the mailboxes, so I made a quick and dirty script which I thought I would share here. Emphasis on quick and dirty here. :)

PowerShell Magic - Add Department Property to Google User Export

Okay okay, it's not magic, but this is still a great use case for some quick and dirty PowerShell scripting. Context: Google Mail is unable to export a user list that includes the 'Department' field that is being synchronized from Active Directory, but I am being asked to take a google export of several thousand users from another group, and add the Department field from AD into the export. Fortunately, PowerShell makes this kind of task a breeze!

Using PowerShell to Remove Old AD Computers

A common problem I see at different businesses is a ton of computer objects just hanging out in Active Directory for machines that were removed from service a long time ago. Here is a quick set of powershell commands I use to get those removed quickly and easily! NOTE: you will need the Microsoft Remote Server Administrator Tools (RSAT) installed and enabled on the machine you are running this on in order to use these modules.

First, you need to make an array that has all of the old computers in it: