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.
A little disclaimer / 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”
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" -whatifAs always, any comments / suggestions with regards to the script are always welcome.
A little disclaimer / 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”
This script was tested under Windows 7 Powershell v2 The script can be downloaded from here:
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.