Hello Romain,
Thank you for your message.
Regarding what you would like to achieve, you could use the API of PRTG to get and filter the name and or address of the devices to keep only those you desire.
To do so, you can use the PowerShell module PRTGAPI (from third party) to get the devices (with the cmdlet Get-Device) and then apply a filter to the command with Where-Object such as :
Get-Device | Where {$_.Host -like "10.0.*"}
Finally, to get all sensors from those devices you need to use a foreach look in which you execute the command below:
Get-Device -Id <DeviceID> | Get-Sensor
Here is a template which might help. Please note that we do not provide official support for it, the latter is provided as is and any modification and usage are up to you.
param(
[string] $hostname = "", # Address of your PRTG server
[string] $username = "", # The username of your PRTG account
[string] $passhash = "" # The passhash of your user account (from Setup > Account Settings > My Account)
)
try {
if(!(Get-PrtgClient)){
Connect-PrtgServer $hostname (New-Credential $username $passhash) -PassHash -IgnoreSSL
}
# Your code goes here
} catch {
write-host "$($_.exception.message) At line : $($_.InvocationInfo.ScriptLineNumber)" -ForegroundColor Red
}
If you have questions, do not hesitate.
Regards.
Add comment