Hello,
I want to ask if there is any way to do a sensor what check if any mailbox got as example 95% of its size used and then change the status to red and show the mailbox with the "problem". I dont want to do a single Sensor for every Mailbox and set max size manually, would be way to much work & sensors.
Thanks for you comming replys!
br
Article Comments
Thanks for your reply! I tried to run the script but I am not able to run it via exchange PS. I get an error that he dont know the get-mailbox command. How can i solve this? The deposited Windows-account is an administrator on the mailserver.
Thanks for help!
Best Regards
Nov, 2018 - Permalink
Hi,
See here: https://docs.microsoft.com/en-us/powershell/module/exchange/mailboxes/get-mailbox?view=exchange-ps
Microsoft very clearly states:
This cmdlet is available in on-premises Exchange and in the cloud-based service.
Due to that - I suppose you are missing components in your PowerShell environment. I would suggest you install or load all Exchange related components first.
May be one of those too links help you out:
- https://docs.microsoft.com/en-us/powershell/exchange/exchange-server/connect-to-exchange-servers-using-remote-powershell?view=exchange-ps
- https://blogs.technet.microsoft.com/samdrey/2018/04/06/how-to-load-remote-powershell-session-on-exchange-2010-2013-2016-exchange-online-o365-2/
You need to make sure your environment is ready. In theory it might go as far as install a remote-probe on the Exchange server and have the script execute on this probe. Seeing that you can't even execute GET-MAILBOX worries me a bit.
Regards
Florian Rossmark
Nov, 2018 - Permalink
Hi, when i run the script on the exchange management directly i get the following erros:
Es ist nicht möglich, eine Methode für einen Ausdruck aufzurufen, der den NULL hat. In Zeile:16 Zeichen:5 + Add-Member -InputObject $arrElement -MemberType NoteProperty -Nam ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull Es ist nicht möglich, eine Methode für einen Ausdruck aufzurufen, der den NULL hat. In Zeile:17 Zeichen:5 + Add-Member -InputObject $arrElement -MemberType NoteProperty -Nam ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull Es wurde versucht, durch 0 (null) zu teilen. In Zeile:19 Zeichen:5 + Add-Member -InputObject $arrElement -MemberType NoteProperty -Nam ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], RuntimeException + FullyQualifiedErrorId : RuntimeException .......
Dec, 2018 - Permalink
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 youremail@domain.com | 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
Dec, 2018 - Permalink
Cause I love challenges - try this:
Depending on how many mailboxes we talk here, you might need to give the script quite a timeout - this is a time-expensive operation...
Try it out - I am curios if it worked as intended...
Regards
Florian Rossmark
www.it-admins.com
Nov, 2018 - Permalink