Solved

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

Posted on 2011-02-24
3
358 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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks for the reply

Can you give me combined code please to try
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
Synchronize a new Active Directory domain with an existing Office 365 tenant
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

771 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

15 Experts available now in Live!

Get 1:1 Help Now