How can I retrieve a list of usernames configured in PRTG groups and devices?
The following script will give you a sortable list of all usernames configured in devices and groups, which can be filtered as necessary. Simply save it as PRTG-GetCredentials.ps1 and execute it in a PowerShell window. The list will look like this:
Note that inherited can also mean "not configured".
Attention You can't retrieve passwords with this. Only configured domains and usernames.
Here's the actual script:
#requires -version 4.0 # ___ ___ _____ ___ #| _ \ _ \_ _/ __| #| _/ / | || (_ | #|_| |_|_\ |_| \___| # Credential Lister ################### # # What exactly is this? ################### # This script shows you all the configured credentials in PRTG (only domain and username). # This will allow you to discern where a faulty account is stored in case it gets locked due to PRTG # still using outdated credentials. It will show all types of credentials. ################### # # How does it work? ################### # Simply execute the script on your PRTG server and it will show a filterable and sortable list. # Depending on the size of your configuration, it may take a while, please be patient. ################### # # How do I configure the script itself? ################### # The script doesn't need any configuration. # # Version History # ---------------------------- # 1.1 [Bugfix] Groups were discarded and are now included in the view # 1.0 Initial Release # # # # # # # # # # # # # # # # # # # # # # # # # # #region configuration ## PRTG configuration [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) ## nodes $prtgGroups = $configuration.SelectNodes("//group") $prtgDevices = $configuration.SelectNodes("//device") #endregion #region function <# Function Section ################################# All functions of the script are defined here. ############################### #> <# Function Name: This-GetXMLValue ################################# Used For: Retrieving XML values. Returns inherited if the trim fails (i.e. if there's nothing to trim ################################# Parameters: # [xml] object - the object that should have it's node extracted # [string] node - the node you want retrieved ################################# #> function This-GetXMLValue($object,[string]$node){ try { $value = $object.data.$node.trim(); } catch { $value = "Inherited" } return $value; } #endregion $Credentials = foreach($prtgGroup in $prtgGroups){ [pscustomobject]@{ ID = $prtgGroup.ID Name = $prtgGroup.data.name.Trim() Type = "Group" "Windows Domain" = (This-GetXMLValue -node "windowslogindomain" -object $prtgGroup) "Windows Login" = $prtggroup.data.windowsloginusername.InnerText.trim() "Linux Login" = (This-GetXMLValue -node "linuxloginusername" -object $prtgGroup) "ESX Login" = (This-GetXMLValue -node "esxuser" -object $prtgGroup) "Database Login" = (This-GetXMLValue -node "dbuser" -object $prtgGroup) "SNMP Community" = (This-GetXMLValue -node "snmpuser" -object $prtgGroup) } } $Credentials += foreach($prtgDevice in $prtgDevices){ [pscustomobject]@{ ID = $prtgDevice.ID Name = $prtgDevice.data.name.Trim() Type = "Device" "Windows Domain" = (This-GetXMLValue -node "windowslogindomain" -object $prtgDevice) "Windows Login" = $prtgdevice.data.windowsloginusername.InnerText.trim() "Linux Login" = (This-GetXMLValue -node "linuxloginusername" -object $prtgDevice) "ESX Login" = (This-GetXMLValue -node "esxuser" -object $prtgDevice) "Database Login" = (This-GetXMLValue -node "dbuser" -object $prtgDevice) "SNMP Username" = (This-GetXMLValue -node "snmpuser" -object $prtgDevice) } } $Credentials | Out-GridView -Title "PRTG Credentials"
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.