Quantcast
Channel: Exchange Server 2013 - Administration, Monitoring, and Performance 论坛
Viewing all articles
Browse latest Browse all 3457

Get-MailboxExportRequest script causes high cpu utilization

$
0
0

Our Exchange configuration is as follows:

  • Exchange 2013 Ent on single server with 4 dbs
  • DB1 - 191 users
  • DB2 - 19 users
  • DB3 - 72 users
  • DB4 - 7 users

When I run a script that exports all of the users from each db to a pst file the CPU utilization peaks as expected, however DB1 never completes.  Is there a way to throttle the performance somewhat or limit the number of users the script processes at a time?  Here is my script:

************************************************************************

#Establish variables
$mailserver = "Exchange"
$path = "\\FileServer"
$userlist = Get-Mailbox -database DB1
$ReportShare = "\\FileServer\pst$\reports"
$file = "\\FileServer\pst$\reports\*.txt"
$SMTP = "smtp.domain.com"

#delete files from previous nights export
if (Test-Path $file)
{
Remove-Item $file
}

#Clear previously completed & failed tasks
Get-MailboxExportRequest | where {$_.status -eq "Completed"} | Remove-MailboxExportRequest -confirm:$false
Get-MailboxExportRequest | where {$_.status -eq "Failed"} | Remove-MailboxExportRequest -confirm:$false

#Perform Mailbox Export
foreach ($user in $userlist)

{
$useralias = $user.alias
New-MailboxExportRequest -Mailbox $useralias -filepath $path\pst$\$useralias.pst
}

#Create a loop which checks if the task has completed or not
$exstat = Get-MailboxExportRequest | Get-MailboxExportRequestStatistics | where {$_.status -eq 'inprogress'}
do {start-sleep -seconds 5; $exstat = Get-MailboxExportRequest | Get-MailboxExportRequestStatistics | where {$_.status -eq 'inprogress'}}
until ($exstat.percentcomplete -eq '100')

#Create a pause for the exports to finish before writing logfile output
start-sleep -seconds 7200

#Write output to a log file
if ($ReportShare)
{
Write-Output "Writing reports to $($ReportShare)"
$Completed = Get-MailboxExportRequest -BatchName $BatchName | Where {$_.Status -eq "Completed"} | Get-MailboxExportRequestStatistics | Format-List
if ($Completed)
{
$Completed | Out-File -FilePath "$($ReportShare)\$($BatchName)_Completed.txt"
}
$Incomplete = Get-MailboxExportRequest -BatchName $BatchName | Where {$_.Status -ne "Completed"} | Get-MailboxExportRequestStatistics | Format-List
if ($Incomplete)
{
$Incomplete | Out-File -FilePath "$($ReportShare)\$($BatchName)_Incomplete_Report.txt"
}
}

#Send a mail notification the task has completed
Get-ChildItem $ReportShare | where {-NOT $_.PSIsContainer} | foreach {$_.fullname} | Send-MailMessage -to "notify_IT@domain.com" -from "Exchange@domain.com" -Subject "PST EXPORT REPORT DB1" -Body "Export of DB1 complete." -SmtpServer $SMTP -BodyAsHtml


Viewing all articles
Browse latest Browse all 3457

Trending Articles



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