I am trying to create a script for my job and I need to read a xml file to check if there are any duplicated parameter. So far I can output the table but I haven't been able to export as any kind of file (log, csv, etc)
The idea is to run the script and get this information for many remote servers.
This is my current progress.
$SectionName = 'np'
$path = "S:\Docker\NP6\Volumes\smartupdate\config\SmartUpdateLocal.xml"
[xml] $xml = Get-Content $path
$param = $xml.SelectSingleNode("//Section[@name='$SectionName']")
$table = $param.Parameter
$table
And the table can be seen:
But since I will be running this script for thousand of servers I would like to export something like:
---------Server A------------
Name Value
ena.. true
base.. 0
sto.. 22592
ena.. EAI
---------Server B------------
Name Value
ena.. true
base.. 0
sto.. 22592
ena.. EAI
The XML format is
<SmartUpdate>
<Settings>
<Section name="np">
<Parameter name="enableStatusFileCreation" value="true" />
<Parameter name="baseStatusCode" value="0" />
<Parameter name="storeId" value="43001" />
<Parameter name="enableTransportMechanismAndPackage" value="true"/>
<Parameter name="statusTransportMechanism" value="EAI" />
</Section>
</Settings>
</SmartUpdate>
Also I am looping the remote servers
$computerList = Get-Content $DeviceListFilePath
foreach($computer in $computerList)
{
$SectionName = 'np'
Write-Host "OPENING XML FILE" -ForegroundColor Yellow
$path = "\\$server_ip\$FileName"
[xml] $xml = Get-Content $path
$param = $xml.SelectSingleNode("//Section[@name='$SectionName']")
Thank you for the help.