Link to home
Start Free TrialLog in
Avatar of Jon Brelie
Jon BrelieFlag for United States of America

asked on

Need help with out-file addition to powershell script

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!
ASKER CERTIFIED SOLUTION
Avatar of KenMcF
KenMcF
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jon Brelie

ASKER

Perfect!

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

Thanks!