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
Solved

Need help with out-file addition to powershell script

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Exchange server is not supported in any cloud-hosted platform (other than Azure with Azure Premium Storage).
A list of top three free exchange EDB viewers that helps the user to extract a mailbox from an unmounted .edb file and get a clear preview of all emails & other items with just a single click on mailboxes.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
how to add IIS SMTP to handle application/Scanner relays into office 365.

828 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