Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Move mailboxes querying the ntaccount name in a txt file. In exchange 2007.

Posted on 2011-02-24
3
Medium Priority
?
375 Views
Last Modified: 2012-06-27
Hi,

Move mailboxes querying the ntaccount name in a txt file. In exchange 2007.

I want help with a script that can check each user name in the txt file and move mailboxes from one server store to another server store.

A log file if possible with success and failure.

regards
Raja
0
Comment
Question by:bsharath
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 16

Accepted Solution

by:
Dale Harris earned 2000 total points
ID: 34977258
I just did this with a CSV I exported from our Exchange.

Let's say you have a CSV outputted with alias for each one.  That means it can be queried through your AD by using "Domain\$alias".  If this doesn't work, then you will have to adjust accordingly.

So what I did was set up the variable to hold all of the accounts:

$Accounts = import-csv "C:\Users.csv"

Then you can simply do whatever you want with this information now:

$Accounts | %{move-mailbox -identity "Domain\$($_.alias)" -targetdatabase "$TargetDB"}

This is assuming that above the fields you want to use, is the word alias.

Now if you were doing a text file, I would do:

$Accounts = get-content "C:\TextFile.txt"

And the code would change just a little to the below:
$Accounts | %{move-mailbox -identity "Domain\$_" -targetdatabase "$TargetDB"}


HTH,

Dale Harris
0
 
LVL 16

Expert Comment

by:Dale Harris
ID: 34977266
Forgot to add this bit:

You can run this in the Powershell window, and it will return errors as it tries to move accounts if it encounters any.

This is a pretty straight forward issue, but if you really wanted to keep track in a text file, you could look into using the Start-Transcript and Stop-Transcript commands.  This will capture anything in the window.

DH
0
 
LVL 11

Author Comment

by:bsharath
ID: 34977270
Thanks for the reply

Can you give me combined code please to try
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

715 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