Author: techadmin
Updated: Exchange Mailbox Cleaner
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.
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”
Maximize My SendSize
Someone asked me the other day, “How could I go about using Security Groups, to control users’ send size limits?” He basically had a limit of 2mb for all users, and wanted to allow users in a specific Security Group to send up to 50mb messages. Here is a basic breakdown of the process I suggested: Firstly, you need to confirm that the global transport limit is raised to 50mb.
You can view and set these limits using get-transportconfig and set-transportconfig respectively:
Get-TransportConfig | select MaxSendSize
The next step would involve setting the send connector to allow 50mb messages. You can use get-sendconnector to get a list of all send connectors, and their respective limits.
Get-SendConnector | Select Name, MaxMessageSize
And then use set-sendconnector to set the MaxSendSize Set-SendConnector “Connector Name” –MaxSendSize 50mb Finally, you need to control the individual users’ send limits. If you have to control it via groups, you can use the following command to first enumerate the users in the group, and then pipe that to the set-mailbox command. Replace testsizegroup with the group you need to control the size limits for.
((get-group "testsizegroup").members) | foreach {set-mailbox -identity $_.Name -maxsendsize 52428800}
This will set the MaxSendSize for all users in that group to 50 mb. This command will have to be rerun every time to add users to the group, so it would be advisable to schedule this command to run hourly / daily etc.