May 09 2018 11:05 AM
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
May 09 2018 11:37 PM
SolutionYou 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
}
}
May 09 2018 11:37 PM
SolutionYou 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
}
}