User’s unable to delete mail from their mailbox

Do you have an issue, where your users are unable to delete mail from their mailboxes? Does the mail being deleted, disappear from their mailbox and reappear? Does your Organization make user of “Retention Policies” from Microsoft Purview?

If your answer is yes to all 3 of the above questions, then your users “TotalDeletedItemSize” has most likely reach the size quota (the quota for this sub-folder is 100GB).

You can check this, either directly for an individual user or by exacting a list of all users.

If you want to do this directly on an individual user, you can make use of the below script

Connect-ExchangeOnline

get-mailbox [email protected] | Get-MailboxStatistics  | select DisplayName,ItemCount,TotalItemSize,DeletedItemCount,TotalDeletedItemSize 

If you want to pull a list of all user, into a csv file, you can make use of the below script. Please make sure to update the location of where toy want the csv file to be exported to.

Connect-ExchangeOnline

get-mailbox -ResultSize unlimited | Get-MailboxStatistics  | select DisplayName,ItemCount,TotalItemSize,DeletedItemCount,TotalDeletedItemSize | export-csv C:\scripts\UsersRetentionSizes.csv -NoTypeInformation -Append

Once you have this information and have found the users that have reached the 100GB size quota, on their “TotalDeletedItemSize” folder, you will need to follow the below steps to remove the Retention Policy being applied to their mailbox. Once the Retention Policy has been removed from the user, the “TotalDeletedItemSize” folder will start to be cleared.

Please note that this is not immediate and can take up to 30 days for the Retention Policy to stop applying to the user, but there are ways to speed this up.

I followed the below article from Microsoft to remove the Retention Policy from the user, but they failed to mention 1 key command that forces the process to beginning. Without forcing the process to start, you will be waiting 30 days or more for the “TotalDeletedItemSize” folder to be cleaned up.

https://learn.microsoft.com/en-us/microsoft-365/compliance/delete-items-in-the-recoverable-items-folder-of-mailboxes-on-hold?view=o365-worldwide

Using the above mentioned article, I have managed to stream line the process. (well at least I think so, as it works for me)

The very first thing you will need to do, is to go to the Microsoft Compliance Portal (also known as Microsoft Purview), then open the “Data lifecycle management” and then the “Retention Policies Tab”.

You will need then need to find and edit the Retention Policy, defined for Exchange Online, and add the required user/users to the “Excluded” option. Once added, I would recommend waiting about an hour or so just for backend M365 replication to take place, but its not necessarily required.

Once the user have been “Excluded” from the Exchange Online Retention Policy, the below Exchange Online PowerShell commands will need to be run. Please be sure to update the command with the required users UPN.

Connect-ExchangeOnline

Set-Mailbox [email protected] -SingleItemRecoveryEnabled $false
Set-Mailbox [email protected] -RetainDeletedItemsFor 1
Set-Mailbox [email protected] -LitigationHoldEnabled $false
Set-Mailbox [email protected] -RemoveDelayHoldApplied
Set-Mailbox [email protected] -RemoveDelayReleaseHoldApplied

Once the above commands have been run, the final step is to force the processing to start using the ManagedFolderAssistant

Start-ManagedFolderAssistant [email protected]

You may need to run the above command multiple times, over the course of a few days.

You can now monitor the size of the “TotalDeletedItemSize” folder, but using the previously mentioned PowerShell command for the individual mailbox.

get-mailbox [email protected] | Get-MailboxStatistics | select DisplayName,ItemCount,TotalItemSize,DeletedItemCount,TotalDeletedItemSize

Once the users “TotalDeletedItemSize” folder has reduced down to 0GB or any other acceptable size, it is strongly recommended that you do back to the Exchange Retention policy and remove the used from being Excluded.

We also recommend that you run the below commands to reset the users mailbox setting, back to their original state. This can be done by using the below commands.

Set-Mailbox [email protected] -SingleItemRecoveryEnabled $true
Set-Mailbox [email protected] -RetainDeletedItemsFor 14
Set-Mailbox [email protected] -LitigationHoldEnabled $true

Please note that we take no responsibility for any issues caused by these commands and it is up to YOU to review and ensure that these commands can be run in your environment.

Check free space on volume mount points

Wow! It’s been a while since I have posted any scripts! This is mainly due to the fact that I am rather busy at work, and also working hard at completing my MCITP.

A while back a client of mine, asked if there was an easy way to use one computer to check the free space of mount points. This was a real problem for them, as the administrators would come in every morning and manually logon to each server, and use disk management to check the free space.

I was certain that there had to be a WMI object for mount points, so after a little digging, I came up with the following script:

$TotalGB = @{Name="Capacity(GB)";expression={[math]::round(($_.Capacity/ 1073741824),2)}}
$FreeGB = @{Name="FreeSpace(GB)";expression={[math]::round(($_.FreeSpace / 1073741824),2)}}
$FreePerc = @{Name="Free(%)";expression={[math]::round(((($_.FreeSpace / 1073741824)/($_.Capacity / 1073741824)) * 100),0)}}
 
function get-mountpoints {
$volumes = Get-WmiObject -computer $server win32_volume | Where-object {$_.DriveLetter -eq $null}
$volumes | Select SystemName, Label, $TotalGB, $FreeGB, $FreePerc | Format-Table -AutoSize
}
 
$servers = (Get-Content .servers.txt)
 
foreach ($server in $servers){
get-mountpoints
}

The script is written to collect server names from a text file, but you could use any other method to supply you server names.

Hope this helps someone else!