# Author: Scott Sutherland, NetSPI (@_nullbind / nullbind) function Get-TomcatUsers { param ( [Parameter(Mandatory = $true)] [string]$TomcatConfigFile ) # Load the XML file [xml]$xml = Get-Content -Path $TomcatConfigFile # Create an array to store the results $usersList = @() # Select the user nodes from the XML $users = $xml.'tomcat-users'.user # Loop through each user and extract the name and password attributes foreach ($user in $users) { # Create a PowerShell object for each user $userObject = [PSCustomObject]@{ Username = $user.name Password = $user.password } # Add the object to the list $usersList += $userObject } # Display the list of users as a table return $usersList } # Example usage $tomcatConfigFilePath = "c:\temp\configs\tomcat-users.xml" Get-TomcatUsers -TomcatConfigFile $tomcatConfigFilePath | Format-Table -AutoSize <# tomcat-users.xml #>