Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #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){
- if( $node -eq "windowsloginpassword" ){
- try { $value = $object.data.windowsloginpassword.cell.trim(); }
- catch { $value = "Inherited" }
- }
- else{
- 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" = (This-GetXMLValue -node "windowsloginusername" -object $prtgGroup)
- "Windows Passwd" = (This-GetXMLValue -node "windowsloginpassword" -object $prtgGroup)
- "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" = (This-GetXMLValue -node "windowsloginusername" -object $prtgDevice)
- "Windows Passwd" = (This-GetXMLValue -node "windowsloginpassword" -object $prtgDevice)
- "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"
Advertisement
Add Comment
Please, Sign In to add comment