display RSOP XML security settings in Powershell for baseline comparisom

$xmlfile = "C:\share\dev.xml"
$xmldoc = New-Object System.XML.XMLDocument

$xmldoc.Rsop.ComputerResults.ExtensionData.Extension |
Where-Object { $_.type -match 'SecuritySettings' } |
Select-Object -ExpandProperty UserRightsAssignment |
Select-Object -Property Name, @{
Name = 'Members'
Expression = { $_.Member.Name.'#text' -join ', ' }

Hi I am a new powershell user and just started training in XML. I am trying to display RSOP security settings in powershell so that I can export to CSV to do baseline comparison.

I managed to display the User Right Assignment part of the RSOP security settings, but i have difficulty display the folowing:

<strong>Security Settings\Local Policies\Audit Policy
Security Settings\Local Policies\Security Options
Security Settings\Event Log
Computer Configuration\Preferences\Windows Settings\Registry
Windows Settings\Advanced Audit Policy Configuration\Audit Policies\System</strong>

I can display password policy and password lockout policy using Get-ADDefaultDomainPasswordPolicy , but is it better to display it from RSOP XML output.

As for being new to PS, this is fine, we’ve all been there, but it is vital that you get yourself ramped up, to limit / avoid, many misconceptions, confusion, errors, bad habits, etc… that you are going to encounter.

YouTube, Microsoft Virtual Academy, MS Channel9, TechNet Virtual Labs are all free and you friend. Just search for PowerShell videos and / or labs on those resources.

Use the 'Free Resources' link in the left menu.

You can also leverage these Q&A resources.


And this…


There are XML cmdlets built into PSv2x and higher as well as modules you can install from the MS PowerShellGallery.
Using the .Net namespace is fine as well, yet get in the habit of starting with what is built in.

# See all XML modules
Find-Module -Name '*xml*'

# Download all XML module to target profile
Find-Module -Name '*xml*' | 
Format-Table -AutoSize | 
Save-Module -Path "$env:USERPROFILE\Documents\WindowsPowerShell\Modules"

# Install all XML modules
Install-Module -Name '*xml*'
Get-Command -Name '*xml*' | Format-Table -AutoSize

CommandType Name                      Version     Source
----------- ----                      -------     ------
Cmdlet      ConvertTo-Xml        Microsoft.PowerShell.Utility
Cmdlet      Export-Clixml        Microsoft.PowerShell.Utility
Cmdlet      Import-Clixml        Microsoft.PowerShell.Utility
Cmdlet      Select-Xml           Microsoft.PowerShell.Utility

With any properly formatted XML file. You should only need to do —

Import-CliXml -Path 'C:\share\dev.xml'

— and work with the displayed properties directly.