Writing a basic script
As we have seen in the In-Place hold section, the Recoverable Items folder has its own storage quota and has Deletions, Versions, Purges, Audits, Discovery Holds, and Calendar Logging as subfolders. This script will loop through the mailboxes and export the size of these subfolders to a CSV file.
The $Output
is an empty array used later to store the output of the script. The $Mbx
array stores the list of mailboxes. We then use Foreach
to loop through the mailboxes in $Mbx
. Note the usage of two if-else
statements for the Audits and Discovery Holds section in the script, which are present to ensure that we don't get errors if the user is not enabled for Mailbox Auditing and In-Place holds respectively.
We have created a new object to create a new instance of a PowerShell object and used the Add-Member cmdlet custom Properties to that object and store it in the $report
variable for each mailbox in the list. The results are then added to the $Output
array defined earlier...