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


PRTG does not show text in Sensor

Votes:

0

Your Vote:

Up

Down

When execute this script the text is not displayed. Instead PRTG shows "Ung�ltige Eingabe".

How do i show the Exchange Version?

<#
===================================================================================
Paessler PRTG Sensor to check Exchange Server Version
===================================================================================
Autor:        Stefan Redlin
Script:       CheckExchangeVersion.ps1
Version:      1.0
Date:         26.04.2019
Environment:  Windows Server 2016/Exchange2016
Scriptpath:   C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML
Scripttype:   EXE/Script Advanced
#>
$result = Invoke-Command -ComputerName EX-01 {$query = Get-Command Exsetup.exe | select Version
$query}


$Version = $result.version.ToString()
$output= switch ($Version){

15.1.225.16 {"Exchange Server 2016 Preview"}
15.1.225.42 {"Exchange Server 2016 RTM"}
15.1.396.30 {"Exchange Server 2016 Cumulative Update 1 (CU1)"}
15.1.466.34 {"Exchange Server 2016 Cumulative Update 2 (CU2)"}
15.1.544.27	{"Exchange Server 2016 Cumulative Update 3 (CU3)"}
15.1.669.32 {"Exchange Server 2016 Cumulative Update 4 (CU4)"}
15.1.845.34 {"Exchange Server 2016 Cumulative Update 5 (CU5)"}
15.1.1034.26 {"Exchange Server 2016 Cumulative Update 6 CU6"}
15.1.1261.35 {"Exchange Server 2016 Cumulative Update 7 (CU7)"}
15.1.1415.2 {"Exchange Server 2016 Cumulative Update 8 (CU8)"}
15.1.1466.3	 {"Exchange Server 2016 Cumulative Update 9 (CU9)"}
15.1.1531.3 {"Exchange Server 2016 Cumulative Update 10 (CU10)"}
15.1.1591.01 {"Exchange Server 2016 Cumulative Update 11 (CU11)"}
15.1.1713.5 {"Exchange Server 2016 Cumulative Update 12 (CU12)"}
default {"Ungültige Eingabe"}
}


Write-Host @"
<prtg>
<result>
<channel>Exchange Version</channel>
<value>0</value>
</result>
<text>$output</text>
</prtg>
"@

Output looks like

<prtg>
<result>
<channel>Exchange Version</channel>
<value>0</value>
</result>
<text>Exchange Server 2016 Cumulative Update 6 CU6</text>
</prtg>

exchange powershell prtg sensor

Created on Apr 26, 2019 2:55:40 PM by  SRedlin (0) 1

Last change on Apr 26, 2019 4:27:21 PM by  Birk Guttmann [Paessler Support]



9 Replies

Votes:

0

Your Vote:

Up

Down

SRedlin,

Would it be possible for you to upload an image of the sensor, and link it here?

I need to see what error message the sensor is showing.

Benjamin Day
Paessler Support

Created on Apr 29, 2019 9:13:29 AM by  Benjamin Day [Paessler Support]



Votes:

0

Your Vote:

Up

Down

Hey Benjamin, here is the link to the image https://ibb.co/f8rW2BB

Like i said in my first post i recieve "Ung�ltige Eingabe" instead of the Exchange Version in PRTG GUI

Created on Apr 29, 2019 9:23:22 AM by  SRedlin (0) 1



Votes:

0

Your Vote:

Up

Down

SRedin,

In your script you have the entry for "default {"Ungültige Eingabe"}" in your switch table.

This would lead me to think the value returned is not one within the scope you've set.

Can you have your script output the version number for testing?

Benjamin Day
Paessler Support

Created on Apr 29, 2019 11:02:35 AM by  Benjamin Day [Paessler Support]



Votes:

0

Your Vote:

Up

Down

When i uncomment the line "default {"Ungültige Eingabe"}" the sensor output changes to OK.

In Powershell ISE i got Exchange Server 2016 Cumulative Update 6 CU6 as output for the variable $output. So i think my value for the version seems to be correct.

<prtg> <result> <channel>Exchange Version</channel> <value>0</value> </result> <text>Exchange Server 2016 Cumulative Update 6 CU6</text> </prtg>

Created on Apr 29, 2019 12:17:37 PM by  SRedlin (0) 1



Votes:

0

Your Vote:

Up

Down

SRedin,

So what does the Message field in the sensor say now?

Benjamin Day
Paessler Support

Created on Apr 29, 2019 12:58:17 PM by  Benjamin Day [Paessler Support]



Votes:

0

Your Vote:

Up

Down

When i uncomment the line "default {"Ungültige Eingabe"}" the sensor output changes to OK. https://ibb.co/VQsdPSS

Created on Apr 29, 2019 1:07:16 PM by  SRedlin (0) 1



Votes:

0

Your Vote:

Up

Down

Hello, as script returns "ungültige Eingabe" even if the actual call fails. I'd "enable" logging within the script by writing the content of $result perhaps into its own logfile (or even adding this to the output-line to PRTG).

Write-Host @"
<prtg>
<result>
<channel>Exchange Version</channel>
<value>0</value>
</result>
<text>$result</text>
</prtg>
"@

This should show any eventual error messages then.

Created on Apr 30, 2019 6:23:20 AM by  Torsten Lindner [Paessler Support]



Votes:

0

Your Vote:

Up

Down

Changed the script a little bit, for troubleshooting proposes.

<#
===================================================================================
Paessler PRTG Sensor to check Exchange Server Version
===================================================================================
Autor:        Stefan Redlin
Script:       CheckExchangeVersionV2.ps1
Version:      1.0
Date:         01.05.2019
Environment:  Windows Server 2016/Exchange2016
Scriptpath:   C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML
Scripttype:   EXE/Script Advanced
$result = Invoke-Command -ComputerName EX-01 {$query = Get-Command Exsetup.exe | select Version
$query}
#>


$result = Invoke-Command -ComputerName EX-01 -ScriptBlock {$query = Get-Command Exsetup.exe | select Version
$query}

$Version = $result.version.ToString()
$Version|Out-file C:\temp\Version.txt
$content = Get-Content C:\temp\Version.txt
#region: XML Output for PRTG
Write-Host "<prtg>" 
if($Version -eq "15.1.225.16"){$Count=1}else{$count=0}
Write-Host "<result>"
               "<channel>Exchange Server 2016 Preview</channel>"
               "<value>$Count</value>"
               "<text>Exchange Server 2016 Preview</text>"
               "</result>"
if($Version -eq "15.1.225.42"){$Count=1}else{$count=0}
Write-Host "<result>"
               "<channel>Exchange Server 2016 RTM</channel>"
               "<value>$Count</value>"
               "<text>Exchange Server 2016 RTM</text>"
               "</result>"
if($Version -eq "15.1.396.30"){$Count=1}else{$count=0}
Write-Host "<result>"
               "<channel>Exchange Server 2016 CU1</channel>"
               "<value>$Count</value>"
               "<text>Exchange Server 2016 CU1</text>"
               "</result>"
if($Version -eq "15.1.466.34"){$Count=1}else{$count=0}
Write-Host "<result>"
               "<channel>Exchange Server 2016 CU2</channel>"
               "<value>$Count</value>"
               "<text>Exchange Server 2016 CU2</text>"
               "</result>"
if($Version -eq "15.1.544.27"){$Count=1}else{$count=0}
Write-Host "<result>"
               "<channel>Exchange Server 2016 CU3</channel>"
               "<value>$Count</value>"
               "<text>Exchange Server 2016 CU3</text>"
               "</result>"
if($Version -eq "15.1.669.32"){$Count=1}else{$count=0}
Write-Host "<result>"
               "<channel>Exchange Server 2016 CU4</channel>"
               "<value>$Count</value>"
               "<text>Exchange Server 2016 CU4</text>"
               "</result>"
if($Version -eq "15.1.845.34"){$Count=1}else{$count=0}
Write-Host "<result>"
               "<channel>Exchange Server 2016 CU5</channel>"
               "<value>$Count</value>"
               "<text>Exchange Server 2016 CU5</text>"
               "</result>"
if($content -eq "15.1.1034.26"){[string]$Count='1'}else{[string]$count='0'}
Write-Host "<result>"
               "<channel>Exchange Server 2016 CU6</channel>"
               "<value>$Count</value>"
               "<text>Exchange Server 2016 CU6</text>"
               "</result>"
Write-Host "</prtg>" 
#endregion

##########################################################################

If i run the script in Powershell or ISE, a textfile for debugging is been written, if i open the file i can see the value 15.1.1034.26 which indicates Exchange Server 2016 CU6. When PRTG EXE/Script Advanced Sensor is executing the script the file is empty.

Why does PRTG have this behavior and how can i fix it?

Second problem, when i just import the file which includes the version number with get-content and run the sensor the if else statement also do not work like expected.

ISE and Powershell Output for Channel Exchange 2016 CU6

<result>
<channel>Exchange Server 2016 CU6</channel>
<value>1</value>
<text>Exchange Server 2016 CU6</text>
</result>

Created on May 1, 2019 9:23:09 AM by  SRedlin (0) 1

Last change on May 1, 2019 9:35:30 AM by  Dariusz Gorka [Paessler Support]



Votes:

0

Your Vote:

Up

Down

If the script doesn't write into the file when executed by PRTG, it could mean, it doesn't even get to the part when executed by PRTG (consider permissions when you run the script vs. when PRTG runs it as LOCAL SYSTEM). Also, a "<text>" - property inside the channel result doesn't work. There can only be one <text> outside of the channel results in the XML. You have to change it from:

<result>
<channel>Exchange Server 2016 CU6</channel>
<value>1</value>
<text>Exchange Server 2016 CU6</text>
</result>

to:

<result>
<channel>Exchange Server 2016 CU6</channel>
<value>1</value>
</result>
<text>Exchange Server 2016 CU6</text>

Created on May 1, 2019 9:52:15 AM by  Torsten Lindner [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.