Solved

Move Mailbox Powershell Script Questions

Posted on 2009-07-01
3
812 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Lotus Notes – formerly IBM Notes – is an email client application, while IBM Domino (earlier Lotus Domino) is an email server. The client possesses a set of features that are even more advanced as compared to that of Outlook. Likewise, IBM Domino is…
This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
This video discusses moving either the default database or any database to a new volume.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

815 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

8 Experts available now in Live!

Get 1:1 Help Now