What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

Custom XML EXE Sensor remote Powershell

Votes:

0

Hello,

I want to execute a Powershell script from a remote probe to another server within the same network. When I change the param $ComputerName to a valid value I get results like I should, but when I put the script in PRTG it does not show any values. Even when I specify the computername manually.

This is the script that I use:

param( [string]$ComputerName = "defaulthost" )

enter-pssession $ComputerName

$value= Get-WmiObject -Query "SELECT * FROM Win32_Processor" -ComputerName $ComputerName $LoadPercentage = $value.LoadPercentage

$value2= Get-WmiObject -Query "SELECT * FROM Win32_OperatingSystem" -ComputerName $ComputerName $FreePhysicalMemory = $value2.FreePhysicalMemory/1024

$MemoryUsed = ($value2.FreePhysicalMemory/$value2.TotalVisibleMemorySize) * 100 $PercentMemoryUsed = "{0:N2}" -f $MemoryUsed $PercentMemoryUsed = $PercentMemoryUsed -replace ("," , ".")

Write-Host "<prtg>"

Write-Host "<result>" Write-Host "<channel>Processor Percentage</channel>" Write-Host "<value>$LoadPercentage</value>" Write-Host "<float>1</float>" Write-Host "<showTable>1</showTable>" Write-Host "<showChart>1</showChart>" Write-Host "<unit>Go</unit>" Write-Host "<mode>Absolute</mode>" Write-Host "<warning>0</warning>" Write-Host "</result>"

Write-Host "<result>" Write-Host "<channel>Beschikbaar Geheugen MB</channel>" Write-Host "<value>$FreePhysicalMemory</value>" Write-Host "<float>1</float>" Write-Host "<showTable>1</showTable>" Write-Host "<showChart>1</showChart>" Write-Host "<unit>Go</unit>" Write-Host "<mode>Absolute</mode>" Write-Host "<warning>0</warning>" Write-Host "</result>"

Write-Host "<result>" Write-Host "<channel>Beschikbaar Geheugen %</channel>" Write-Host "<value>$PercentMemoryUsed</value>" Write-Host "<float>1</float>" Write-Host "<showTable>1</showTable>" Write-Host "<showChart>1</showChart>" Write-Host "<unit>Go</unit>" Write-Host "<mode>Absolute</mode>" Write-Host "<warning>0</warning>" Write-Host "</result>"

Write-Host "</prtg>"

exit-pssession

Or is there another way to use remote Powershell and PRTG?

Thanks in advance!

powershell remote-commands wmi

Created on Apr 5, 2016 7:33:42 AM



1 Reply

Votes:

0

Hello Ferron,

Which version of PRTG are you running at the moment? Please do also forward the output of the script for further investigation.

Best regards, Felix

Created on Apr 5, 2016 12:59:17 PM by  Felix Saure [Paessler Support]




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.