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

x
?
Solved

Need help with out-file addition to powershell script

Posted on 2011-03-10
2
Medium Priority
?
545 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 2000 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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

If you troubleshoot Outlook for clients, you may want to know a bit more about the OST file before doing your next job. IMAP can cause a lot of drama if removed in the accounts without backing up.
Know the reasons and solutions to move/import EDB to New Exchange Server. Also, find out how to recover an Exchange .edb file and to restore the file back.
The viewer will learn how to dynamically set the form action using jQuery.
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

670 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