David Sankovsky
asked on
Export Mailboxes to PST in bulk, but in batches
Dear Experts, I'm taking over a client that has recently migrated to a new EXCH 19 installation which went smoothly but is cluttered with old and unused mailboxes which belong to disabled users.
I have identified said mailboxes rather easily using the following script:
What I'm looking to do is to modify said script so that for every mailbox's samaccountname, The script will check AD Extention attribute Numer 10 - if it has the word "Exported" in it, skip said mailbox - otherwise, export the mailbox to a PST and after completion edit the Extention Attribute Number 10 to say "Exported"
Also, I don't want to to immediately export all mailboxes found as it is over 1K mailboes and I fear it will kill the storage's IOpS capacity, so I'd like to somehow limit it to 5 simultaneous exports while the rest wait in a queue if that makes sense
I have identified said mailboxes rather easily using the following script:
$Mailboxes = Get-Mailbox -ResultSize Unlimited | where {$_.RecipientTypeDetails -eq 'UserMailbox'}
$Disabled=@()
Foreach ($Mailbox in $Mailboxes) {
if((Get-ADUser -Identity $Mailbox.SamAccountName).Enabled -eq $False){
$count += 1
#$Disabled += Get-MailboxStatistics $Mailbox.SamAccountName | Select -Property DisplayName,TotalItemSize,samaccountname,alias
$Disabled += [pscustomobject]@{
"Username" = $Mailbox.SamAccountName
"Alias" = $Mailbox.Alias
"Display Name" = (Get-MailboxStatistics $Mailbox.SamAccountName).DisplayName
"Total Item Size (MB)" = (Get-MailboxStatistics $Mailbox.SamAccountName).TotalItemSize.Value.ToMB()
}
}
}
$Disabled | Export-Csv -Path $env:userprofile\desktop\DisabledADUserwithMailbox.csv -NoTypeInformation -Encoding UTF8
Write-Host "Found" $count "Mailboxes of Disabled Users"
So far is the easy part.What I'm looking to do is to modify said script so that for every mailbox's samaccountname, The script will check AD Extention attribute Numer 10 - if it has the word "Exported" in it, skip said mailbox - otherwise, export the mailbox to a PST and after completion edit the Extention Attribute Number 10 to say "Exported"
Also, I don't want to to immediately export all mailboxes found as it is over 1K mailboes and I fear it will kill the storage's IOpS capacity, so I'd like to somehow limit it to 5 simultaneous exports while the rest wait in a queue if that makes sense
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I have recommended this question be closed as follows:
Accept: 'Robert' (https:#a43318560)
If you feel this question should be closed differently, post an objection and the moderators will review all objections and close it as they feel fit. If no one objects, this question will be closed automatically the way described above.
seth2740
Experts-Exchange Cleanup Volunteer