Solved

Move Mailbox Powershell Script Questions

Posted on 2009-07-01
3
809 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
This tutorial will walk an individual through the steps necessary to configure their installation of BackupExec 2012 to use network shared disk space. Verify that the path to the shared storage is valid and that data can be written to that location:…
This tutorial will show how to configure a single USB drive with a separate folder for each day of the week. This will allow each of the backups to be kept separate preventing the previous day’s backup from being overwritten. The USB drive must be s…

762 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

6 Experts available now in Live!

Get 1:1 Help Now