Solved

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

Posted on 2011-02-24
3
369 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
  • 2
3 Comments
 
LVL 16

Accepted Solution

by:
Dale Harris earned 500 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

In this previous article (https://oddytee.wordpress.com/2016/05/05/provision-new-office-365-user-and-mailbox-from-exchange-hybrid-via-powershell/), we made basic license assignments to users in O365. When I say basic, the method is the simplest way …
Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

770 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