Last active
July 9, 2021 14:19
-
-
Save Trimad/a5e8441d1cc5767df7826e43a4402eaa to your computer and use it in GitHub Desktop.
autoexpandingarchive
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Get connected to Exchage Online Management | |
Import-Module ExchangeOnlineManagement | |
Connect-ExchangeOnline -UserPrincipalName <UPN> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Confirm that AutoExpandingArchiveEnabled is True and pay attention to what the RetentionPolicy is set to. | |
#If RetentionPolicy is set to "Default MRM Policy", confirm that it includes the property "Default 18 months move to archive" | |
Get-Mailbox <UPN> | FL AutoExpandingArchiveEnabled,RetentionPolicy | |
#Example output: | |
#AutoExpandingArchiveEnabled : True | |
#RetentionPolicy : 9 Month Auto-Archive | |
#Confirm that RetentionHoldEnabled is not True | |
#Reference: https://docs.microsoft.com/en-us/exchange/mailbox-retention-hold-exchange-2013-help | |
Get-Mailbox <UPN> | FL RetentionHoldEnabled | |
#If RetentionHoldEnabled is True, set it to False: | |
Set-Mailbox <UPN> -RetentionHoldEnabled $false | |
#Check the total size of the mailbox: | |
Get-MailboxStatistics <UPN> | FL TotalItemSize | |
#Example output: | |
#TotalItemSize : 47.99 GB (51,528,994,198 bytes) | |
#Run the following command in Exchange Online PowerShell to enable auto-expanding archiving for your entire organization. | |
#Reference: https://docs.microsoft.com/en-us/microsoft-365/compliance/enable-unlimited-archiving?view=o365-worldwide#more-information | |
Set-OrganizationConfig -AutoExpandingArchive | |
#Use the Start-ManagedFolderAssistant cmdlet to immediately start messaging records management (MRM) processing of mailboxes that you specify. | |
#Reference:https://docs.microsoft.com/en-us/powershell/module/exchange/start-managedfolderassistant?view=exchange-ps | |
Start-ManagedFolderAssistant <UPN> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#This script iterates through every mailbox in the organization and saves a report in .csv format. | |
$Result=@() | |
$mailboxes = Get-Mailbox -ResultSize Unlimited | |
$totalmbx = $mailboxes.Count | |
$i = 1 | |
$mailboxes | ForEach-Object { | |
$i++ | |
$mbx = $_ | |
$size = $null | |
Write-Progress -activity "Processing $mbx" -status "$i out of $totalmbx completed" | |
if ($mbx.ArchiveStatus -eq "Active"){ | |
$mbs = Get-MailboxStatistics $mbx.UserPrincipalName | |
if ($mbs.TotalItemSize -ne $null){ | |
$size = [math]::Round(($mbs.TotalItemSize.ToString().Split('(')[1].Split(' ')[0].Replace(',','')/1MB),2) | |
}else{ | |
$size = 0 } | |
} | |
$Result += New-Object -TypeName PSObject -Property $([ordered]@{ | |
ArchiveMailboxSizeInMB = $size | |
ArchiveName =$mbx.ArchiveName | |
ArchiveQuota = if ($mbx.ArchiveStatus -eq "Active") {$mbx.ArchiveQuota} Else { $null} | |
ArchiveState =$mbx.ArchiveState | |
ArchiveStatus =$mbx.ArchiveStatus | |
ArchiveWarningQuota=if ($mbx.ArchiveStatus -eq "Active") {$mbx.ArchiveWarningQuota} Else { $null} | |
AutoExpandingArchiveEnabled=$mbx.AutoExpandingArchiveEnabled | |
RetentionHoldEnabled=$mbx.RetentionHoldEnabled | |
UserName = $mbx.DisplayName | |
UserPrincipalName = $mbx.UserPrincipalName | |
}) | |
} | |
$Result | Export-CSV "Archive-Mailbox-Report.csv" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$mailboxes = Get-Mailbox -ResultSize Unlimited | |
$totalmbx = $mailboxes.Count | |
$i = 1 | |
# Iterate through all mailboxes in the organization | |
# If archiving is already enabled but the auto-expanding archive is not enabled, enable the auto-expanding archive. | |
foreach($mbx in $mailboxes){ | |
$i++ | |
Write-Progress -activity "Processing $mbx" -status "$i out of $totalmbx completed" | |
if($mbx.ArchiveStatus -eq "Active" -and $mbx.AutoExpandingArchiveEnabled -eq $false){ | |
Write-Output $mbx.UserPrincipalName | |
Enable-Mailbox $mbx.UserPrincipalName -AutoExpandingArchive | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$mailboxes = Get-Mailbox -ResultSize Unlimited | |
$totalmbx = $mailboxes.Count | |
$i = 1 | |
# Iterate through all mailboxes in the organization | |
# If a mailbox is on retention hold, take it out of retention hold | |
foreach($mbx in $mailboxes){ | |
$i++ | |
Write-Progress -activity "Processing $mbx" -status "$i out of $totalmbx completed" | |
if($mbx.RetentionHoldEnabled -eq $true){ | |
Write-Output $mbx.UserPrincipalName | |
Set-Mailbox $mbx.UserPrincipalName -RetentionHoldEnabled $false | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment