How to combine the PowerShell script to export list of Disabled AD user mailbox with Mailbox size column?

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 5 years and 6 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
ITEngineer
Posts: 216
Last visit: Thu Mar 23, 2023 5:45 pm
Has voted: 4 times

How to combine the PowerShell script to export list of Disabled AD user mailbox with Mailbox size column?

Post by ITEngineer »

Hi People,

I need someone to assist me in modifying the script below so it is showing all Disabled AD user account with Exchange User mailbox still enabled (not Shared Mailbox)?

Because the script below also returns Shared Mailboxes which is always created as disabled AD user account.

Code: Select all

$Allusers = Get-ADUser -Filter {(enabled -eq $false)} -Properties homeMDB, mailNickName, mail, DisplayName, SamAccountName, Givenname, SurName | ?{ $_.homeMDB -ne $null }
$Allusers | Select-Object Givenname, Surname, DisplayName, Mail, MailNickName, SamAccountName, homeMDB | Export-Csv "C:\DisabledMBXusers.csv" -NoTypeInformation
It would be good if there is mailbox size as well in the column in MBytes.

Like in the below script:

Code: Select all

Get-Mailbox -ResultSize Unlimited |
  Get-MailboxStatistics |
  Select DisplayName,StorageLimitStatus, `
  	@{name="TotalItemSize (MB)"; expression={[math]::Round(($_.TotalItemSize.ToString().Split("(")[1].Split(" ")[0].Replace(",","")/1MB),2)}}, `
  	ItemCount |
  Sort "TotalItemSize (MB)" -Descending
Thank you in advance.
/* IT Engineer */
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: How to combine the PowerShell script to export list of Disabled AD user mailbox with Mailbox size column?

Post by jvierra »

I can recommend posting in the Exchange forum to learn how to use the Exchange CmdLets and how to work with Shared mailboxes.

You could also search for blog posts discussing how to work with shared mailboxes.

Example:

Get-Mailbox -RecipientTypeDetails SharedMailbox

https://www.google.com/search?newwindow ... 8_9RlwafkI
User avatar
ITEngineer
Posts: 216
Last visit: Thu Mar 23, 2023 5:45 pm
Has voted: 4 times

Re: How to combine the PowerShell script to export list of Disabled AD user mailbox with Mailbox size column?

Post by ITEngineer »

jvierra wrote: Fri Aug 31, 2018 1:55 am I can recommend posting in the Exchange forum to learn how to use the Exchange CmdLets and how to work with Shared mailboxes.

You could also search for blog posts discussing how to work with shared mailboxes.

Example:

Get-Mailbox -RecipientTypeDetails SharedMailbox

https://www.google.com/search?newwindow ... 8_9RlwafkI
Yes, I can now find the Attributes that is msExchRecipientTypeDetails :) thanks for the suggestion.
/* IT Engineer */
This topic is 5 years and 6 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked