I am in need of a Powershell script that will check a list of machines for 2 specific values in an XML file. I am not sure where I am going wrong ( a bit new to Powershell) and could use an extra set of eyes on my code.
Code:
## Import data from CSV$ImportFile = Import-Csv "C:\Users\UserName\Desktop\Scripts\Powershell\Epic\SCCM CI\Tags.csv"
foreach ($Computer in $ImportFile){
## Set the location of the XML file on the Remote Machines
$path = "\\$Computer\c$\Epic\bin\7.9.2\Epic Print Service\"
## Select XML node and determine if ArchiveHours = 12 and DeleteHours =120
$xml = select-xml -path "$path\EpicPullService.config.xml" -xpath //EpicPullService//Cleanup | Select -ExpandProperty Node
if ($xml.ArchiveHours -eq '12' -and $xml.DeleteHours -eq '120') {
$Compliance = $True
}Else{
$Compliance = $False
}
##Computer and Complaince (True or False) out to CSV file
} "$Computer","$Compliance" | Export-Csv "C:\Users\UserName\Desktop\Scripts\Powershell\Epic\SCCM CI\Results.csv"
Results:
select-xml : Cannot find path '\\@{SW0908-2364=SW1409-15995}\c$\Epic\bin\7.9.2\Epic Print Service\\EpicPullService.config.xml' because it does not exist.At C:\Users\Username\Desktop\Scripts\Powershell\Epic\SCCM CI\Check_PullServiceXML.ps1:4 char:8
+ $xml = select-xml -path "$path\EpicPullService.config.xml" -xpath //EpicPullServ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (\\@{SW0908-2364...vice.config.xml:String) [Select-Xml], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.SelectXmlCommand
select-xml : Cannot find path '\\@{SW0908-2364=SW1409-16373}\c$\Epic\bin\7.9.2\Epic Print Service\\EpicPullService.config.xml' because it does not exist.
At C:\Users\Username\Desktop\Scripts\Powershell\Epic\SCCM CI\Check_PullServiceXML.ps1:4 char:8
+ $xml = select-xml -path "$path\EpicPullService.config.xml" -xpath //EpicPullServ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (\\@{SW0908-2364...vice.config.xml:String) [Select-Xml], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.SelectXmlCommand
select-xml : Cannot find path '\\@{SW0908-2364=SW1412-16985}\c$\Epic\bin\7.9.2\Epic Print Service\\EpicPullService.config.xml' because it does not exist.
At C:\Users\Username\Desktop\Scripts\Powershell\Epic\SCCM CI\Check_PullServiceXML.ps1:4 char:8
+ $xml = select-xml -path "$path\EpicPullService.config.xml" -xpath //EpicPullServ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (\\@{SW0908-2364...vice.config.xml:String) [Select-Xml], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.SelectXmlCommand