Solved

Move Mailbox Powershell Script Questions

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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Can LDAP and LDAPS function together on a 2012 R2 server? 11 31
Removing Exchange 2003 3 17
exchange 7 23
EXCHANGE 2010, EXCHANGE 2013 4 22
This article outlines the process to identify and resolve account lockout in an Active Directory environment.
This article demonstrates probably the easiest way to configure domain-wide tier isolation within Active Directory. If you do not know tier isolation read https://technet.microsoft.com/en-us/windows-server-docs/security/securing-privileged-access/s…
how to add IIS SMTP to handle application/Scanner relays into office 365.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

733 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