Solved

Need help with out-file addition to powershell script

Posted on 2011-03-10
2
543 Views
Last Modified: 2012-05-11
I'm jumping in at the last minute to migrate some mailboxes off of an exchange server to another online host.  I was given the following script to facilitate the mailbox transfers, but I would like to add some logging so that I can check on progress and/or modify the input file if it needs to be restarted for any reason.  

Basically I just need to know where to put the 'out-file' command in this script:

$users = Import-Csv -Path "users.csv"

If (!$scred) {$scred = Get-Credential "SOURCE CREDENTIALS"}
If (!$tcred) {$tcred = Get-Credential "TARGET CREDENTIALS"}

$users | ForEach-Object {
                $SourceIdentity = $_.Identity
                Start-Transcript -Path "$SourceIdentity.txt" -Append
                Move-XsExchangeMailboxToExchangeOnline –SourceIdentity $SourceIdentity -SourceCredential $scred -
AllowUnsecureConnection -GlobalCatalog "GLOBAL CATALOG SERVER"  -TargetCredential $tcred -

Verbose
                Stop-Transcript
}

Open in new window


That way I can just keep an eye on the output and modify the input file to remove completed users if the task needs to be restarted.

Thanks!
0
Comment
Question by:Enphyniti
[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 Comments
 
LVL 27

Accepted Solution

by:
KenMcF earned 500 total points
ID: 35096467
You have a transcript for the logging already it looks like. But without testing it does not look like it would work, is it working for you when you run the script?

Try to change this line
Start-Transcript -Path "$SourceIdentity.txt" -Append  

to this, change D:\Logs to the location you want to log files.

Start-Transcript -Path "d:\logs\$($SourceIdentity).txt" -Append  
0
 
LVL 16

Author Closing Comment

by:Enphyniti
ID: 35096779
Perfect!

The script didn't work, but the logging piece did exactly what you said it would.

Thanks!
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

MS Outlook is a world-class email client application that is mainly used for e-communication globally.  In this article, we will discuss the basic idea about MS Outlook, its advanced features, and types of MS Outlook File formats.
This article explains how to install and use the NTBackup utility that comes with Windows Server.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
This video discusses moving either the default database or any database to a new volume.

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