The following will also show it in a Gridview which allows you to filter:
param(
$prtgProtocol = "http", # http or https
$prtghost = "prtg.acme.com", # the hostname, e.g. prtg.acme.com
$prtgPort = 80, # the port used by PRTG
$prtgUser = "prtgadmin", # the username
$prtgPasshash = 123456789 # the user's passhash
)
$Sensors = ((Invoke-WebRequest -URI "$($prtgProtocol)://$($prtghost):$($prtgPort)/api/table.json?content=sensors&output=json&columns=objid,device,sensor&username=$($prtgUser)&passhash=$($prtgPasshash)").Content | ConvertFrom-Json)
$Devices = ((Invoke-WebRequest -URI "$($prtgProtocol)://$($prtghost):$($prtgPort)/api/table.json?content=devices&output=json&columns=objid,device&username=$($prtgUser)&passhash=$($prtgPasshash)").Content | ConvertFrom-Json)
$List = @();
$List.Clear();
Foreach($Device in $Devices.devices){
$Sensors = ((Invoke-WebRequest -URI "$($prtgProtocol)://$($prtghost):$($prtgPort)/api/table.json?content=sensors&output=json&id=$($Device.objid)&columns=objid,device,sensor&username=$($prtgUser)&passhash=$($prtgPasshash)").Content | ConvertFrom-Json)
Foreach($Sensor in $Sensors.sensors){
$Channels = ((Invoke-WebRequest -URI "$($prtgProtocol)://$($prtghost):$($prtgPort)/api/table.json?content=channels&output=json&columns=name,lastvalue_,objid&id=$($sensor.objid)&username=$($prtgUser)&passhash=$($prtgPasshash)").Content | ConvertFrom-Json);
Foreach($Channel in $Channels.channels){
$ChannelSettings = (Invoke-WebRequest -Uri "$($prtgProtocol)://$($prtghost):$($prtgPort)/controls/channeledit.htm?_hjax=true&id=$($Sensor.objid)&channel=$($Channel.objid)&username=$($prtgUser)&passhash=$($prtgPasshash)");
if(($channel.objid -eq -4) -or $Channel.name -eq "Execution Time"){ continue;}
$ChannelUnit = $ChannelSettings.InputFields.FindById("customunit_$($Channel.objid)").Value
#$ChannelUnit = $ChannelSettings.InputFields.FindById("unit_$($Channel.objid)").Value
[pscustomObject]$sensorItem = New-Object -TypeName psobject;
$sensorItem | Add-Member -MemberType NoteProperty -Name "Object ID" -Value $Device.objid
$sensorItem | Add-Member -MemberType NoteProperty -Name "Device" -Value $Device.device
$sensorItem | Add-Member -MemberType NoteProperty -Name "Sensor ID" -Value $Sensor.objid
$sensorItem | Add-Member -MemberType NoteProperty -Name "Sensor" -Value $Sensor.sensor
$sensorItem | Add-Member -MemberType NoteProperty -Name "Channel ID" -Value $Channel.objid
$sensorItem | Add-Member -MemberType NoteProperty -Name "Channel Name" -Value $Channel.name
$sensorItem | Add-Member -MemberType NoteProperty -Name "Lower Warning Limit" -Value $ChannelSettings.InputFields.FindById("limitminwarning_$($Channel.objid)").value
$sensorItem | Add-Member -MemberType NoteProperty -Name "Lower Error Limit" -Value $ChannelSettings.InputFields.FindById("limitminerror_$($Channel.objid)").value
$sensorItem | Add-Member -MemberType NoteProperty -Name "Upper Warning Limit" -Value $ChannelSettings.InputFields.FindById("limitmaxwarning_$($Channel.objid)").value
$sensorItem | Add-Member -MemberType NoteProperty -Name "Upper Error Limit" -Value $ChannelSettings.InputFields.FindById("limitmaxerror_$($Channel.objid)").value
$sensorItem | Add-Member -MemberType NoteProperty -Name "Unit" -Value $($ChannelUnit)
$List += $sensorItem
}
}
}
$List | Out-GridView -Title "PRTG | Sensor Thresholds"
Add comment