Posted by: Colin Smith
Exchange Scripting, Powershell, Scripting
Sorry for the long delay in posts but I have been moving and it is a mess. We purchased a prevously owned home and I will never do that again. New is the only way to go. But now that we are settling in and things are starting to wind down I love the house. Still a ton to do though.
Anyway back to the script. Visiting back I am working on a script that will make some big changes to our exchange environment. I actually have the script completed, tested, and have run it in production with success. So lets continue. Last we were here we validated the user and mailbox by looking at the user object in AD and comparing that with the mailbox object from Exchange. Now that we know we have the correct user and mailbox lets do something. The first thing we must do, now that we have the user object, the mailbox, and a list of all used smtp addresses, we must filter to see if this user meets the requirements for the change to be made and if so what change. For me, management had laid out a list of reasons why a mailbox would not be modified at all and why a mailbox might only have an alias added and not have the primary smtp address updated.
for example, if a user had the company field in AD set to Contoso then I might only add an alias but not change that users primary address. Or say a user has a current primary of @ms.com I might not make any changes at all. In order to do this we just need to grab the properties that we would like to filter against. Once we have those I just used if statements and then set an exclusion flag. Once the Exclusion flag has been set then I know what actions to take or not take on the mailbox.
if (($department -eq “MS”) -or ($department -eq “Microsoft”) -or ($department -eq “Apple”))
$script:exclusion = 1
So you can see that if the users department field is equal to any of those that I set the exclusion flag to 1. Now I know what I need to do with this users mailbox and I can act appropriately.
Now that we now how to act next time we will look at how to do that.