Solved

Need help with out-file addition to powershell script

Posted on 2011-03-10
2
534 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
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Resolve DNS query failed errors for Exchange
Easy CSR creation in Exchange 2007,2010 and 2013
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

708 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

14 Experts available now in Live!

Get 1:1 Help Now