Solved

Move Mailbox Powershell Script Questions

Posted on 2009-07-01
3
811 Views
Last Modified: 2012-06-21
We are in the process of upgrading to Exchange 2007.  When a user is created our tech desk has not done a good job of creating the mailbox in the correct store.  So I am doing a cleanup now to move mailboxes to their correct stores.  Going forward I would like to have a powershell script run weekly to move and misconfigured mailboxes. Here is the command

Get-Mailbox -OrganizationalUnit "SAIUsers" -Filter "Department -eq 'IS'" |Move-Mailbox -TargetDatabase "ISStore"


My questions are
1. Will this work?
2. Can that be piped to a log file of some kind?
3. What would you recommend for Users that do not have the department attribute set?  I need to get a list so i can send it to the tech desk for fixing.


The exchange serves are running on 2008 boxes and the domain is 2003.
0
Comment
Question by:SAIonline
  • 2
3 Comments
 
LVL 27

Expert Comment

by:shauncroucher
ID: 24755994
1) Yes, this command should work fine. You can clarify what results you will get with this command by appending -whatif to the end of the command.

2) | out-File filename.txt should output to a text file

3) It depends what users you are trying to filter for? If you want to filter for all those with Department eq to IS then thats fine. What do you mean those that don't have the dept att set? Well, you could catch all those that do not have any department set by using -eq "" I guess?

Shaun
0
 
LVL 2

Author Comment

by:SAIonline
ID: 24756233
Thank you for the output.  I did figure out that you have to user get-user to use the department filter.  

My plan is to have a line for each department.  If the mailbox is already in the correct store it won't do anything.  (this should be the majority of users.)  If it is not, move the mailbox to the correct store.

The last line would be the one that searches for any blank departments and outputs to a text file.  I think you answered that one too.
Get-User -OrganizationalUnit "SAIUsers" -Filter "Department -eq ''" | out-File filename.txt

Does that look correct?
0
 
LVL 27

Accepted Solution

by:
shauncroucher earned 500 total points
ID: 24756663
For users that don't have a department set AT ALL (so blank) you would need to type  the following:

-Filter "Department -ne '*'" (In other words, not equal to anything. :S)

That should do the trick though!

Shaun
0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains in simple steps how to renew expiring Exchange Server Internal Transport Certificate.
A procedure for exporting installed hotfix details of remote computers using powershell
This tutorial will walk an individual through locating and launching the BEUtility application to properly change the service account username and\or password in situation where it may be necessary or where the password has been inadvertently change…
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now