This script will take a google user export, find mailboxes matching the email addresses in Exchange, and disable the mailboxes. Make sure you are not letting Google AD Sync synchronize until you are done with this process.
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. :)
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!
I ran into a really quick and easy way to add/remove properties from powershell objects or arrays of objects, and wanted to share it. Basically, you just pipe an object into itself while selecting the all of the properties you want, even if they don't exist. Let's have a look...
First, make a new object with a Name property.
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: