OpenandSearchXML

From Terminal23wiki

Jump to: navigation, search

This is just an example of working in XML in PowerShell. This is not really a complete script, just a part of a script I wrote.

[xml]$xmlSetupFile = get-content $strXMLSetuppath
   foreach ($i in $arrServiceAccounts)
      { 
         $pass = $xmlSetupFile.Setup.creds.cred | where-object {$_.user -match "$i"}
         $arrServicePasswords += $pass.pass
      }

[string]$strLocalComputerName = get-content env:COMPUTERNAME
$objServerMatches = $xmlSetupFile.setup.servers.internal.server | where-object {$_.env -match "$strEnvironment" -and $_.pcwinsvcs -match 'true' -and $_.servername -match "$strLocalComputerName"}
Personal tools