Good morning. Today I wanted to post a couple of quick one line PowerShell commands for Exchange 2010. I used both of these today and they are invaluable in certain situations.
The first command is used to load local Exchange Shell. Normally you don’t want to do this, but I had issues with RBAC (Role Based Access Control) that prevented doing anything in Exchange Shell or Exchange Management Console.
- Run a PowerShell command as Administrator
- Run: Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
The second command is very useful in multi-domain exchange forests. For instance if multiple user accounts are in a child domain, but Exchange is in the parent domain, and you need to move the mailboxes.
Here is the command without setting the AD server setting parameter:
Get-Mailbox -Database “Mailbox Database” -Domaincontroller DC.child.domain.com | New-MoveRequest -TargetDatabase “New Database” -Domaincontroller DC.child.domain.com
Here is the command to change the behavior of Exchange Shell to mimic Exchange Management Console:
Set-AdServerSettings -ViewEntireForest $True
And the resulting command to move mailboxes as above:
Get-Mailbox -Database “Mailbox Database” | New-MoveRequest -TargetDatabase “New Database”
I hope you have found this article informative. If you have any comments or suggestions, please leave them below.