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




I have the following custom script:

$connection = Connect-VIServer -Server xxx.xxx.xxx.xxx -User xxxx -Password xxxx

Write-Host "<prtg>"

ForEach ($VM in Get-VM | where-object {($_.powerstate -ne "PoweredOff") }){

ForEach ($Drive in $VM.Extensiondata.Guest.Disk) {
    $Path = $Drive.DiskPath

    $Freespace = [math]::Round($Drive.FreeSpace / 1MB)
    $Capacity = [math]::Round($Drive.Capacity/ 1MB)

    $PercentFree = [math]::Round(($FreeSpace)/ ($Capacity) * 100) 

    #VMs with less space

    if ($PercentFree -lt 20) {     

      $message = "$VM $Path"

      Write-Host "<result>"

      Write-Host "<channel>$message</channel>"

      write-host "<LimitMinWarning>20</LimitMinWarning>"

      write-host "<LimitMinError>10</LimitMinError>"

      Write-Host "<LimitMode>1</LimitMode>"

      Write-Host "<value>$PercentFree</value>"

      Write-Host "<unit>Percent</unit>"

      Write-Host "</result>"     




Write-Host "</prtg>"

An if I try to use it as a sensor I get a JSON error.

error json powershell script

Created on Jul 2, 2019 3:41:22 PM

Last change on Jul 3, 2019 12:19:20 PM by  Torsten Lindner [Paessler Support]


Nobody has replied yet

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.