<\/use><\/svg><\/div><\/a><\/div><\/p>","upvoteCount":1,"datePublished":"2019-05-20T02:46:05.000Z","url":"https://community.spiceworks.com/t/mailbox-statistics/712103/9","author":{"@type":"Person","name":"sunithphilip9607","url":"https://community.spiceworks.com/u/sunithphilip9607"}},{"@type":"Answer","text":"hmm that is odd<\/p>\n
This is Exchange online right?<\/p>","upvoteCount":1,"datePublished":"2019-05-20T11:44:51.000Z","url":"https://community.spiceworks.com/t/mailbox-statistics/712103/10","author":{"@type":"Person","name":"gregory-for-microsoft","url":"https://community.spiceworks.com/u/gregory-for-microsoft"}},{"@type":"Answer","text":"
Yes exchange online<\/p>","upvoteCount":0,"datePublished":"2019-05-20T12:33:50.000Z","url":"https://community.spiceworks.com/t/mailbox-statistics/712103/11","author":{"@type":"Person","name":"sunithphilip9607","url":"https://community.spiceworks.com/u/sunithphilip9607"}},{"@type":"Answer","text":"
foreach($users in Get-Mailbox -ResultSize Unlimited){$users | Foreach-Object {\n\n$user = $_\n\n$stats = Get-MailboxStatistics $user.userprincipalname\n\n$a=get-user $user.userprincipalname\n\nNew-Object -TypeName PSObject -Property @{\n\nDisplayName = $User.DisplayName\n\nIssueWarningQuota = $User.IssueWarningQuota\n\nProhibitSendQuota = $User.ProhibitSendQuota\n\nProhibitSendReceiveQuota = $user.ProhibitSendReceiveQuota\n\nTotalItemSize = $stats.TotalItemSize\n\n}\n\n}\n\n}\n<\/code><\/pre>\nI am able to get the output with the above. However,<\/p>\n
\n\nI need the TotalItemSize to show in MB<\/p>\n<\/li>\n
\nHave TotalItemSize in Descending order<\/p>\n<\/li>\n<\/ol>\n
Appreciate if you can assist me on how to change the code<\/p>","upvoteCount":0,"datePublished":"2019-05-20T15:14:21.000Z","url":"https://community.spiceworks.com/t/mailbox-statistics/712103/13","author":{"@type":"Person","name":"sunithphilip9607","url":"https://community.spiceworks.com/u/sunithphilip9607"}},{"@type":"Answer","text":"
Add<\/p>\n
@{name=“TotalItemSize (MB)” ;<\/p>\n
| Sort “TotalItemSize (MB)” -Descending<\/p>\n
at the appropriate position<\/p>","upvoteCount":0,"datePublished":"2019-05-21T07:47:22.000Z","url":"https://community.spiceworks.com/t/mailbox-statistics/712103/14","author":{"@type":"Person","name":"beverlygao","url":"https://community.spiceworks.com/u/beverlygao"}}]}}
We are Office365.
We need to Generate a report in CSV that will give us
Display Name
MailBox Size (which i believe is TotalItemSize)
Mailbox Quota
I want this to be displayed in descending order based on TotalItemSize
Appreciate your advise and help
4 Spice ups
This is the basic PowerShell I use -
Get-Mailbox -ResultSize Unlimited |
Get-MailboxStatistics |
Select DisplayName, `
@{name=“TotalItemSize (MB)”; expression={[math]::Round( `
($_.TotalItemSize.ToString().Split(“(”)[1].Split(" “)[0].Replace(”,“,”")/1MB),2)}}, `
ItemCount |
Sort “TotalItemSize (MB)” -Descending
1 Spice up
Inkmaster has your back and is on point here.
Report back if you need more
1 Spice up
Run this, it works in my environment.
get-mailbox -server “server” -ResultSize unlimited |Where {$.UseDatabaseQuotaDefaults -eq $false} |Select-Object DisplayName,IssueWarningQuota,ProhibitSendQuota,@{label=“TotalItemSize(MB)”;expression={(get-mailboxstatistics $ ).TotalItemSize.Value.ToMB()}}| Export-Csv “C:\test\UserMailboxSizes.csv” -NoTypeInformation
Here is a similar issue for reference. https://social.technet.microsoft.com/Forums/Windows/en-US/454351f8-bc30-4631-ac0c-077d913fb598/powershell-script-to-generate-quota-mailbox-size-report?forum=exchangesvradminlegacy
@Inkmaster - I like to have the below columns in my report for each user
ProhibitSendQuota
ProhibitSendReceiveQuota
IssueWarningQuota
How do I add these into the below:
Get-Mailbox -ResultSize Unlimited |
Get-MailboxStatistics |
Select DisplayName, `
@{name=“TotalItemSize (MB)”; expression={[math]::Round( `
($_.TotalItemSize.ToString().Split(“(”)[1].Split(" “)[0].Replace(”,“,”")/1MB),2)}}, `
ItemCount |
Sort “TotalItemSize (MB)” -Descending
Get-Mailbox -ResultSize Unlimited |
Get-MailboxStatistics |
Select DisplayName,ProhibitSendQuota,ProhibitSendReceiveQuota,IssueWarningQuota, `
@{name="TotalItemSize (MB)"; expression={[math]::Round( `
($_.TotalItemSize.ToString().Split("(")[1].Split(" ")[0].Replace(",","")/1MB),2)}}, `
ItemCount |
Sort "TotalItemSize (MB)" -Descending
Try that and report back
1 Spice up
I get the below error
At C:\Reports\MailBoxStats04.ps1:9 char:84
+ ... ,"")/1MB),2)}}, `
+ ~
Missing expression after ','.
At C:\Reports\MailBoxStats04.ps1:11 char:1
+ ItemCount |
+ ~~~~~~~~~
Unexpected token 'ItemCount' in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParseException
+ FullyQualifiedErrorId : MissingExpressionAfterToken
Forgot the comma after IssueWarningQuota,
I corrected my post try it again…
1 Spice up
Hi Gregory,
I get the report but some of the fields are blank. please see screenshot below
1 Spice up
hmm that is odd
This is Exchange online right?
1 Spice up
Try this through the web admin portal and report back findings
1 Spice up
foreach($users in Get-Mailbox -ResultSize Unlimited){$users | Foreach-Object {
$user = $_
$stats = Get-MailboxStatistics $user.userprincipalname
$a=get-user $user.userprincipalname
New-Object -TypeName PSObject -Property @{
DisplayName = $User.DisplayName
IssueWarningQuota = $User.IssueWarningQuota
ProhibitSendQuota = $User.ProhibitSendQuota
ProhibitSendReceiveQuota = $user.ProhibitSendReceiveQuota
TotalItemSize = $stats.TotalItemSize
}
}
}
I am able to get the output with the above. However,
I need the TotalItemSize to show in MB
Have TotalItemSize in Descending order
Appreciate if you can assist me on how to change the code
Add
@{name=“TotalItemSize (MB)” ;
| Sort “TotalItemSize (MB)” -Descending
at the appropriate position