SOLVED

mailbox stats

Highlighted
Frequent Contributor

Hi experts, i want to export all my users mailboxes statistics to csv file, their mailbox usage, mailbox quota, while pulling the report i want the mailbox type to be mentioned as  office 365, auditing enabled or not. i tried below script i am getting error plz guide me

 

mailboxstats.ps1 | Export-Csv "C:\MailboxStatics.csv" -notypeinformation

foreach($users in Get-Mailbox -ResultSize Unlimited){$users | Foreach-Object {   
$user = $_ 
$stats = Get-MailboxStatistics $user.Name       
New-Object -TypeName PSObject -Property @{       
DisplayName = $User.DisplayName
IssueWarningQuota = $User.IssueWarningQuota       
ProhibitSendQuota = $User.ProhibitSendQuota       
ProhibitSendReceiveQuota = $User.ProhibitSendReceiveQuota     
TotalItemSize = $stats.TotalItemSize
AuditEnabled = $User.AuditEnabled                 
} 
}
}

 

i am getting below errors

PS] C:\>.\mailboxstats.ps1 | Export-Csv "C:\MailboxStatics.csv" -notypeinformation
At C:\mailboxstats.ps1:6 char:27
+ IssueWarningQuota = $User.?IssueWarningQuota
+                          ~
Missing property name after reference operator.
At C:\mailboxstats.ps1:7 char:27
+ ProhibitSendQuota = $User.?ProhibitSendQuota
+                          ~
Missing property name after reference operator.
At C:\mailboxstats.ps1:8 char:34
+ ProhibitSendReceiveQuota = $User.?ProhibitSendReceiveQuota
+                                 ~
Missing property name after reference operator.
    + CategoryInfo         : ParserError: (:) [], ParseException
    + FullyQualifiedErrorId : MissingPropertyName
1 Reply
Highlighted
Solution

You have some double recursion in the above script, you need to clean it up a bit:

 

foreach ($user in Get-Mailbox -ResultSize Unlimited) {

 

$stats = Get-MailboxStatistics $user.UserPrincipalName       
New-Object -TypeName PSObject -Property @{       
DisplayName = $User.DisplayName
IssueWarningQuota = $User.IssueWarningQuota       
ProhibitSendQuota = $User.ProhibitSendQuota       
ProhibitSendReceiveQuota = $User.ProhibitSendReceiveQuota     
TotalItemSize = $stats.TotalItemSize
AuditEnabled = $User.AuditEnabled                 
} 
}