Powershell Needful Things put that in your pipeline

20May/118

Exchange 2010 stale & unused mailbox cleanup tool

Posted by Jean Louw

I have finally completed the testing of the User Mailbox Cleanup tool for Exchange 2010.

Although this script is run from the EMS, it opens as a GUI utility which Exchange Administrators can use to cleanup stale or old Exchange mailboxes from Exchange 2010 mailbox servers.
The utility has a couple of preset search queries to help locate stale or old mailboxes, and once complete, administrators have various options they can use to remove or cleanup these mailboxes.

The script obviously does not care about the significance of the individual mailboxes, although certain system mailboxes are excluded from the search. You still have to verify your selection before you take action against any items.

The script can be downloaded for free from here:

http://www.powershellneedfulthings.com/?page_id=291

Your comments and feedback with regards to these items are always welcome.

13May/112

Exchange 2010 Cleanup Utility

Posted by Jean Louw

Good news!

I have completed the update of the Exchange mailbox cleanup tool, for use with Exchange 2010.

I don't have access to a 2010 server at the moment to finalise testing.

I should be able to complete testing next week, and post the updated utility to the site.

Filed under: cleanup, exchange 2 Comments
1Sep/090

Updated: Exchange Mailbox Cleaner

Posted by Jean Louw

I am ready to call this the final version of my Exchange Mailbox Cleaner script!

I have successfully used it in production and it saved us the effort of having to find and remove these mailboxes manually.

The GUI also makes it easy to hand this function over to the administrators for future cleanup tasks.

I have added one more search query button, the “Last Logon” button. This button will look for users on the selected server where the LastLogon is equal to $null. This finds accounts which have essentially never logged on. There is a small bug though, if the user name is not unique, it seems that the last logon is unreadable and the account will also show up in the list.

This will however report an ERROR to the shell screen. Mailboxes which have not logged on will report the following warning to the shell:
WARNING: There is no data to return for the specified mailbox 'Bunny, Bugs', because it has not been logged on to.

For now, this is a manual method of verifying that the correct mailboxes will be removed. I am however looking for a way to avoid this and will post an update as soon as I have time to find the solution.

I have also permanently removed the Add-ADPermission from the Export-Mailbox section, as full mailbox access permissions are enough to export the mailbox.

I may build in a check later to see if the permissions are required before adding them.
#Add-ADPermission -Identity $actionItem -User $currentUser -Extendedrights "Send As" -whatif
#Add-ADPermission -Identity $actionItem -User $currentUser -Extendedrights "Receive As" -whatif

As always, any comments / suggestions with regards to the script are always welcome.

The utility requires the Exchange Management shell, and if launched from a Vista / Windows 7 needs to be “Run as Administrator”

This script was tested under Windows 7 Powershell v2.

Full information and the download location for this script can be found here:
http://www.powershellneedfulthings.com/?page_id=293

30Jul/090

Updated: Exchange Mailbox Cleaner

Posted by Jean Louw

I have really been busy lately and have not had much time to spend on scripting. I did however find a litlle time to update this utility.

Here is a list of changes:

  • After completing a query, the utility will now show you the total amount of data used by the mailboxes. (this obviously ignores single instance storage etc.)
  • You can now use the utility to move selected mailboxes to another store (This was a request from Aaron)
  • I have force removed the mandatory “confirm” on the Exchange verbs (move, disabled and delete)

Full information and the download location for this script can be found here:
http://www.powershellneedfulthings.com/?page_id=293

30Jun/096

Cleanup unused Exchange 2007 mailboxes

Posted by Jean Louw

I often use my orphaned home directory cleanup script at work, to recover unused space from our file and print clusters. So my manager recently suggested that I do something similar for Exchange. Knowing that the orphan folder cleanup utility is still my responsibility as the administrators are not too comfortable with running scripts, I decided to give this utility a nice GUI.
To generate the code for the forms, I used SAPIEN PrimalForms. What beautiful tool. Very short learning curve, and very, very powerful. When the form loads, it will get a list of all the Exchange mailbox servers using get-mailboxserver.
This excludes Exchange 2003 servers as get-mailboxstatistics does not work with legacy mailboxes. I may develop a solution for that later. The three query buttons (Disabled, Hidden, Stale) will perform the following actions respectively: Disabled – Find mailboxes linked to disabled AD accounts Hidden – Find mailboxes hidden from the address book.  Stale – Find mailboxes linked to accounts which have not logged on in the last 3 months.
This search may take a little time to complete and this button is not supported against Exchange 2003 servers. These queries will populate the listbox with the names of the mailboxes. Besides the “Export List” button, the Action buttons at the bottom will action only selected items.
You can select items using SHIFT or CTRL. Export List will create a text file containing your search results. Export PST will grant the current user Full Mailbox with Send As and Receive As permission, and then export the mailbox to the path specified. Rename will change the display name based on the query performed. For mailboxes found with the “Disabled” button the display name will be prefixed with “DISABLED-MBXCleaner-“, for “Hidden” with “HIDDEN-MBXCleaner-“ and so forth. Users previously renamed will be excluded from subsequent searches. The “Disable” action will remove Exchange Attributes without deleting the AD account. The mailbox will be removed when the retention time expires. Delete will remove the mailbox and AD account completely.
I have not had a chance to test the Delete button as I would need to submit a change control request before using the utility in our live environment. All of the Action buttons are set to –whatif mode by default. The “Go Hot” checkbox will activate the heavy hitters (Export PST; Rename; Disable and Delete) so you can safely test each button first before taking any action. The “Reserved” button, currently, does nothing. I plan to allow this button to read or build a custom search for users, either by Name or other criteria.
 
WARNING: This is a dangerous utility, and can wreck your Exchange system if you are not careful. Please test this in your test environment first, and adhere to your change control procedures before using this utility in the live environment. I take absolutely no responsibility for any damage caused by using this tool. The utility requires the Exchange Management shell, and if launched from a Vista / Windows 7 needs to be “Run as Administrator”

Full information and the download location for this script can be found here:
http://www.powershellneedfulthings.com/?page_id=293