stephanlinke

PRTG-FindAutoDiscoveries

Oct 19th, 2016
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. [string] $ConfigurationFilePath = ((Get-ItemProperty -Path "hklm:SOFTWARE\Wow6432Node\Paessler\PRTG Network Monitor\Server\Core" -Name "Datapath").DataPath) + "PRTG Configuration.dat"
  2.    [xml] $configuration = New-Object -TypeName XML;
  3.          $configuration.Load($ConfigurationFilePath)
  4.  
  5. [System.Collections.ArrayList]$ADEnabledGroups = @();
  6. [System.Collections.ArrayList]$ADEnabledDevices  = @();
  7.  
  8. $Groups = ($configuration.SelectNodes("//group"))
  9. $Devices = ($configuration.SelectNodes("//device"))
  10.  
  11. foreach($Device in $Devices){
  12.     if($device.data.discoverytype.trim() -ne 0)
  13.     { $ADEnabledDevices.Add($device.id); }
  14. }
  15.  
  16. foreach($Group in $Groups){
  17.     if($group.data.discoverytype.trim() -ne 0)
  18.     { $ADEnabledGroups.Add($group.id); }
  19. }
  20.  
  21. if($ADEnabledDevices.Count -eq 0)
  22. { $DeviceMsg = "No devices with AutoDiscovery found." }
  23. else
  24. { $DeviceMsg = [string]::Format("Devices with AutoDiscovery found: {0} ({1})",$ADEnabledDevices.Count,$ADEnabledDevices -join ", ") }
  25.  
  26. if($ADEnabledGroups.Count -eq 0)
  27. { $GroupMsg = "No groups with AutoDiscovery found." }
  28. else
  29. { $GroupMsg = [string]::Format("Groups with AutoDiscovery found: {0} ({1})",$ADEnabledGroups.Count,$ADEnabledGroups -join ", ") }
  30.  
  31. $Msg = [string]::Format("{0} | {1}",$GroupMsg,$DeviceMsg);
  32. $Count = $ADEnabledGroups.Count + $ADEnabledDevices.Count;
  33.  
  34. Write-Host ([string]::Format("{0}:{1}",$Count,$Msg))
Advertisement
Add Comment
Please, Sign In to add comment