Okay - looking at that and assuming you have the same line numbers - this points to those lines:
Add-Member -InputObject $arrElement -MemberType NoteProperty -Name IssueWarningQuota -Value ([long]($mb.IssueWarningQuota.ToString().TrimEnd(" bytes)").Split("(")[1].Replace(",","").Replace(".","")))
Add-Member -InputObject $arrElement -MemberType NoteProperty -Name ProhibitSendQuota -Value ([long]($mb.ProhibitSendQuota.ToString().TrimEnd(" bytes)").Split("(")[1].Replace(",","").Replace(".","")))
Add-Member -InputObject $arrElement -MemberType NoteProperty -Name PercentUsed -Value ([long](($arrElement.TotalItemSize / $arrElement.ProhibitSendQuota)*100))
Those are 16 through 19.
Now - Interestingly line 15 seems to be happy...
Add-Member -InputObject $arrElement -MemberType NoteProperty -Name TotalItemSize -Value ([long]($ms.TotalItemSize.ToString().TrimEnd(" bytes)").Split("(")[1].Replace(",","").Replace(".","")))
First I assumed a possible language issue with the "bytes" in the string - but it seems like this is not the case.
Looking closer you see that $ms is used in line 15 as source and $mb is used in lines 16 and 17 as source. Line 19 depends again on 16 and 17 and must fail therefor.
To debunk it - just do a this:
Get-Mailbox -Identity [email protected] | fl
I am not certain if the email will work as identity - could be your user as well.. depends on factors.. what I am looking for is the values IssueWarningQuota and ProhibitSendQuota. If they don't exist - this will be an issue. Then you have to find out where you can get them from.
The script was developed against a Office 365 Exchange server. You seem to run on premise - now it depends on the exact version and service pack of your exchange where and if at all you can get those information.
Having said that - assuming the quota limitations are the same for everyone - you could replace 16 through 19 with those lines:
#Add-Member -InputObject $arrElement -MemberType NoteProperty -Name IssueWarningQuota -Value ([long]($mb.IssueWarningQuota.ToString().TrimEnd(" bytes)").Split("(")[1].Replace(",","").Replace(".","")))
Add-Member -InputObject $arrElement -MemberType NoteProperty -Name IssueWarningQuota -Value ([long](111111111))
#Add-Member -InputObject $arrElement -MemberType NoteProperty -Name ProhibitSendQuota -Value ([long]($mb.ProhibitSendQuota.ToString().TrimEnd(" bytes)").Split("(")[1].Replace(",","").Replace(".","")))
Add-Member -InputObject $arrElement -MemberType NoteProperty -Name ProhibitSendQuota -Value ([long](222222222))
Add-Member -InputObject $arrElement -MemberType NoteProperty -Name PercentUsed -Value ([long](($arrElement.TotalItemSize / $arrElement.ProhibitSendQuota)*100))
Here please replace the 11111111 with the warning limit in bytes and the 2222222 with the error / send limit in bytes.
After that the calculation should work.
Hope that helps you... It is just PowerShell in the end - but not every Exchange/PowerShell version provides the same properties - what you clearly see in your case - it depends on the versions used - for the Exchange and PowerShell.
Regards / Grüße
Florian
Add comment