Quantcast
Channel: Exchange Server 2013 - Administration, Monitoring, and Performance forum
Viewing all articles
Browse latest Browse all 1453

PowerShell script to export user mailbox as .PST file from input.CSV

$
0
0

People,

I need some help in modifying the PowerShell script to export user mailbox as .PST from input file below:

The problem is that the input file is from the HR system as First Last name.
How to write the logs to .CSV file when the export failed?

#Import remote session with exchange on my laptop where Outlook is installed$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://PRDEX01-VM/Powershell/ -Authentication KerberosImport-PSSession $Session$ServerBackupUNCPath = "\\FILESERVER\OST\"$CSVPath = "C:\LOGS\users.csv"try{$AllMailboxes = Import-CSV $CSVPathforeach ($mbx in $AllMailboxes) { New-MailboxExportRequest -Mailbox $mbx -FilePath "$ServerBackupUNCPath$($mbx.Alias).pst" -baditemlimit 50 -acceptlargedataloss; while ((Get-MailboxExportRequest -mailbox $i | Where-Object { $_.Status -eq "Queued" -or $_.Status -eq "InProgress" })) { Start-Sleep 120 } }Write-Host"Processing...........$mbx.Alias................" -ForegroundColor Green}catch{Write-Host "Exception has occured processing....$mbx.Alias...." -ForegroundColor Red$_.Exception.Message# Export the list of the failed mailboxes to exportExport-Csv -Path C:\LOGS\FailedExport.CSV -NoTypeInformation}

Any help would be greatly appreciated.

Thanks


/* Server Support Specialist */


Viewing all articles
Browse latest Browse all 1453

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>