Skip to content

Instantly share code, notes, and snippets.

@stephanlinke
Created April 11, 2018 14:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stephanlinke/0125cc4cf664f2c9d9d914b3e9fc1928 to your computer and use it in GitHub Desktop.
Save stephanlinke/0125cc4cf664f2c9d9d914b3e9fc1928 to your computer and use it in GitHub Desktop.
Finds all configured auto discoveries in PRTG
[string] $ConfigurationFilePath = ((Get-ItemProperty -Path "hklm:SOFTWARE\Wow6432Node\Paessler\PRTG Network Monitor\Server\Core" -Name "Datapath").DataPath) + "PRTG Configuration.dat"
[xml] $configuration = New-Object -TypeName XML;
$configuration.Load($ConfigurationFilePath)
[System.Collections.ArrayList]$ADEnabledGroups = @();
[System.Collections.ArrayList]$ADEnabledDevices = @();
$Groups = ($configuration.SelectNodes("//group"))
$Devices = ($configuration.SelectNodes("//device"))
foreach($Device in $Devices){
if($device.data.discoverytype.trim() -ne 0)
{ $ADEnabledDevices.Add($device.id); }
}
foreach($Group in $Groups){
if($group.data.discoverytype.trim() -ne 0)
{ $ADEnabledGroups.Add($group.id); }
}
if($ADEnabledDevices.Count -eq 0)
{ $DeviceMsg = "No devices with AutoDiscovery found." }
else
{ $DeviceMsg = [string]::Format("Devices with AutoDiscovery found: {0} ({1})",$ADEnabledDevices.Count,$ADEnabledDevices -join ", ") }
if($ADEnabledGroups.Count -eq 0)
{ $GroupMsg = "No groups with AutoDiscovery found." }
else
{ $GroupMsg = [string]::Format("Groups with AutoDiscovery found: {0} ({1})",$ADEnabledGroups.Count,$ADEnabledGroups -join ", ") }
$Msg = [string]::Format("{0} | {1}",$GroupMsg,$DeviceMsg);
$Count = $ADEnabledGroups.Count + $ADEnabledDevices.Count;
Write-Host ([string]::Format("{0}:{1}",$Count,$Msg))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment