New Question
 
 
PRTG Network Monitor

Intuitive to Use.
Easy to manage.

200.000 administrators have chosen PRTG to monitor their network. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free PRTG
Download >>

 

What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general. You are invited to get involved by asking and answering questions!

Learn more

 

Top Tags


View all Tags


Exchange Mailbox Monitoring

Votes:

0

Your Vote:

Up

Down

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

email exchange exchange-mailbox mailbox-size prtg

Created on Nov 14, 2018 9:03:50 AM by  ranighte (0) 1



5 Replies

Accepted Answer

Votes:

2

Your Vote:

Up

Down

Cause I love challenges - try this:

param(
    [long]$MaxSizeLimitInPercent = 90
)

$arrCollection=@()

Foreach ($mb in Get-Mailbox){

    $ms = Get-Mailboxstatistics -Identity $mb.Identity
    

    $arrElement = New-Object PSObject
    Add-Member -InputObject $arrElement -MemberType NoteProperty -Name DisplayName -Value $mb.DisplayName
    Add-Member -InputObject $arrElement -MemberType NoteProperty -Name Identity -Value $mb.Identity
    Add-Member -InputObject $arrElement -MemberType NoteProperty -Name TotalItemSize -Value ([long]($ms.TotalItemSize.ToString().TrimEnd(" bytes)").Split("(")[1].Replace(",","").Replace(".","")))
    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))
    
    $arrCollection += $arrElement

}

[string]$MailboxeNames = ""
[int]$MailboxCount = 0
Foreach ($member in $arrCollection){
    if ($member.PercentUsed -gt ($MaxSizeLimitInPercent - 1)) { #-1 since we talk about -gt > and not >=
        $MailboxCount += 1
        If ($MailboxNames.length -gt 0) { $MailboxeNames += ", " }
        $MailboxeNames += $member.DisplayName     
    }
}

$XML = "
<prtg>
    <result>
        <channel>Total Mailboxes Over Size Limit</channel>
        <value>" + $MailboxCount + "</value>
        <LimitMinError>0</LimitMinError>
    </result>
    <text>" + $MailboxeNames + "</text>
</prtg>"

Function WriteXmlToScreen ([xml]$xml) #just to make it clean XML code...
{
    $StringWriter = New-Object System.IO.StringWriter;
    $XmlWriter = New-Object System.Xml.XmlTextWriter $StringWriter;
    $XmlWriter.Formatting = "indented";
    $xml.WriteTo($XmlWriter);
    $XmlWriter.Flush();
    $StringWriter.Flush();
    Write-Output $StringWriter.ToString();
}

WriteXmlToScreen "$XML"

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

Created on Nov 14, 2018 3:59:03 PM by  Florian Rossmark (4,099) 3 2



Votes:

0

Your Vote:

Up

Down

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

Created on Nov 26, 2018 5:57:17 AM by  ranighte (0) 1



Votes:

0

Your Vote:

Up

Down

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:

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

Created on Nov 26, 2018 2:56:06 PM by  Florian Rossmark (4,099) 3 2



Votes:

0

Your Vote:

Up

Down

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

.......

Created on Dec 12, 2018 8:56:06 AM by  ranighte (0) 1



Votes:

0

Your Vote:

Up

Down

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

Created on Dec 12, 2018 2:56:03 PM by  Florian Rossmark (4,099) 3 2

Last change on Dec 12, 2018 7:51:10 PM by  Dariusz Gorka [Paessler Support]



Please log in or register to enter your reply.


Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.