Hi there!
I am pretty new to Powershell and am working on a project where I need to have a comparison between 2 different XML files (which contain exported policies from from 2 different Citrix farms). The aim is to check the consistency between the 2 Citrix farms in terms of policies which are applied, by comparing the two XML files.
The XML output is large. I have tried using both Xpath and import-clixml cmdlets to look into the data.
If I run
[xml]$xmldoc=Get-Content
$xmldoc.documentelement.obj.ms.obj.ms.s
I get the following:
N #text
State NotConfigured
Path XMLService\TrustXmlRequests
State NotConfigured
Value 0
Path XMLService\XmlServicePort
State NotConfigured
Path VirtualIP\EnhancedCompatibility
State NotConfigured
Path VirtualIP\EnhancedCompatibilityPrograms
State NotConfigured
Path VirtualIP\FilterAdapterAddresses
State NotConfigured
Path VirtualIP\FilterAdapterAddressesPrograms
State NotConfigured
Path VirtualIP\VirtualLoopbackPrograms
State NotConfigured
Path VirtualIP\VirtualLoopbackSupport
State NotConfigured
Value 80
Path VirtualDesktopAgent\ControllerRegistrationPort
State NotConfigured
Value
Path VirtualDesktopAgent\Controllers
State NotConfigured
Value
Path VirtualDesktopAgent\ControllerSIDs
State NotConfigured
Value
Path VirtualDesktopAgent\SiteGUID
State NotConfigured
Path VirtualDesktopAgent\CPUUsageMonitoring\CPUUsageMonitoring_Enable
State NotConfigured
Value 60
Path VirtualDesktopAgent\CPUUsageMonitoring\CPUUsageMonitoring_Period
State NotConfigured
Value 95
Path VirtualDesktopAgent\CPUUsageMonitoring\CPUUsageMonitoring_Threshold
State NotConfigured
Value AllowAny
Path ServerSettings\ConnectionAccessControl
State NotConfigured
Path ServerSettings\DnsAddressResolution
State NotConfigured
Path ServerSettings\FullIconCaching
State NotConfigured
Value Default Zone
Path ServerSettings\InitialZone
Now if I try to;
$xmldoc.documentelement.obj.ms.obj.ms.s | where {$_.“#text” -eq “enabled”}
I get:
N #text
State Enabled
State Enabled
State Enabled
State Enabled
State Enabled
State Enabled
State Enabled
State Enabled
State Enabled
State Enabled
State Enabled
State Enabled
State Enabled
State Enabled
State Enabled
State Enabled
Using the Import-CliXML cmdlet:
$xml = Import-Clixml
Now if I see the output, it shows as :
$xml
PolicyName : Policy Name Here
Type : Computer
TrustXmlRequests : @{State=NotConfigured; Path=XMLService\TrustXmlRequests}
XmlServicePort : @{State=NotConfigured; Value=0; Path=XMLService\XmlServicePort}
EnhancedCompatibility : @{State=NotConfigured; Path=VirtualIP\EnhancedCompatibility}
EnhancedCompatibilityPrograms : @{State=NotConfigured; Path=VirtualIP\EnhancedCompatibilityPrograms}
FilterAdapterAddresses : @{State=NotConfigured; Path=VirtualIP\FilterAdapterAddresses}
FilterAdapterAddressesPrograms : @{State=NotConfigured; Values=System.Collections.ArrayList;
Path=VirtualIP\FilterAdapterAddressesPrograms}
VirtualLoopbackPrograms : @{State=NotConfigured; Path=VirtualIP\VirtualLoopbackPrograms}
VirtualLoopbackSupport : @{State=NotConfigured; Path=VirtualIP\VirtualLoopbackSupport}
ControllerRegistrationPort : @{State=NotConfigured; Value=80; Path=VirtualDesktopAgent\ControllerRegistrationPort}
Controllers : @{State=NotConfigured; Value=; Path=VirtualDesktopAgent\Controllers}
ControllerSIDs : @{State=NotConfigured; Value=; Path=VirtualDesktopAgent\ControllerSIDs}
SiteGUID : @{State=NotConfigured; Value=; Path=VirtualDesktopAgent\SiteGUID}
CPUUsageMonitoring_Enable : @{State=NotConfigured; Path=VirtualDesktopAgent\CPUUsageMonitoring\CPUUsageMonitoring_Enable}
CPUUsageMonitoring_Period : @{State=NotConfigured; Value=60;
Path=VirtualDesktopAgent\CPUUsageMonitoring\CPUUsageMonitoring_Period}
CPUUsageMonitoring_Threshold : @{State=NotConfigured; Value=95;
Path=VirtualDesktopAgent\CPUUsageMonitoring\CPUUsageMonitoring_Threshold}
Now all policies show as Properties under get-member cmdlet. How can I extract the fields which have the “State” as not equal to “Not configured” or in other words where “State” is “enabled”?