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

Ask your Windows 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.
Locked
User avatar
ITEngineer
Posts: 145
Joined: Wed Oct 12, 2011 10:52 am

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

Post by ITEngineer » Fri Aug 31, 2018 1:02 am

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 */

User avatar
jvierra
Posts: 13732
Joined: Tue May 22, 2007 9:57 am
Contact:

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

Post by jvierra » 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

User avatar
ITEngineer
Posts: 145
Joined: Wed Oct 12, 2011 10:52 am

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

Post by ITEngineer » Sun Sep 02, 2018 7:18 pm

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 */

Locked