{"id":8513,"date":"2025-01-13T05:22:17","date_gmt":"2025-01-13T05:22:17","guid":{"rendered":"https:\/\/pariswells.com\/blog\/?p=8513"},"modified":"2025-01-13T05:22:19","modified_gmt":"2025-01-13T05:22:19","slug":"powershell-code-to-list-all-users-who-do-not-have-365-archive-enabled-with-mailbox-size-over-20gb","status":"publish","type":"post","link":"https:\/\/pariswells.com\/blog\/research\/powershell-code-to-list-all-users-who-do-not-have-365-archive-enabled-with-mailbox-size-over-20gb","title":{"rendered":"Powershell code to list all users who do not have 365 archive enabled with mailbox size over 20GB"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code class=\"\"># Threshold size in GB\n$thresholdSize = 20\n\n# Get all user mailboxes\n$mailboxes = Get-Mailbox -RecipientTypeDetails UserMailbox -ResultSize Unlimited\n\n# Check each mailbox for size and archiving status\n$mailboxes | ForEach-Object {\n    $mailbox = $_\n    $stats = Get-MailboxStatistics -Identity $mailbox.UserPrincipalName\n    $archiveEnabled = $mailbox.ArchiveStatus -eq \"None\"\n\n    # Extract mailbox size as a string (e.g., \"20 GB\")\n    $sizeString = $stats.TotalItemSize.ToString()\n\n    # Parse the numeric part of the size (e.g., \"20\" from \"20 GB\")\n    if ($sizeString -match \"([\\d\\.]+) GB\") {\n        $mailboxSizeGB = [double]$matches[1]\n\n        # Check if the mailbox exceeds the threshold and archiving is disabled\n        if ($mailboxSizeGB -gt $thresholdSize -and $archiveEnabled) {\n            [PSCustomObject]@{\n                DisplayName       = $mailbox.DisplayName\n                UserPrincipalName = $mailbox.UserPrincipalName\n                MailboxSizeGB     = $mailboxSizeGB\n                ArchiveEnabled    = $mailbox.ArchiveStatus\n            }\n        }\n    }\n} | Format-Table -AutoSize<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-8513","post","type-post","status-publish","format-standard","hentry","category-research"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/8513","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/comments?post=8513"}],"version-history":[{"count":1,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/8513\/revisions"}],"predecessor-version":[{"id":8514,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/8513\/revisions\/8514"}],"wp:attachment":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/media?parent=8513"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/categories?post=8513"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/tags?post=8513"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}