Parsing XML and apply settings for PCs

Hello,

we have a customer with multiple geographical locations. I’m working on automation task where PCs will be configured based on its region and country while rebuild using SCCM tool. Configuration settings includes UI language, Timezone, Keyboard language etc.

First three characters in Computer Name has region and country code. for example ‘AAU’ for PCs in Australia. My goal is to write a PowerShell script which will check for computer name and apply settings based on xml data.

I’m failed to build a script logic which would parse xml data and find appropriate settings for that PC

XML Code as -

Appreciate any guideline/help. Please…!

Thanks

You have to use Gist URL to post XML. However, what you are describing is possible in the Task Sequence without any XML or Powershell scripting if it’s just based off of a computer name. Depending on the settings, this also sounds like something that should be handled by GPO and the systems are just placed in the appropriate geological OU to apply the settings so that the setting are managed centrally.

If you would like assistance on parsing XML, you should post example XML and the code you have tried, errors, problems, etc.

Thanks Rob for suggestion. indeed there are other ways to configure PCs however its customer’s requirement, hence cant think of other options for now :slight_smile:

have mentioned xml code in original post.

You can turn the xml into an object like this:

[xml]$xml = get-content file.xml

If you want to save it as xml again:

$xml.save('file.xml')

Yeah, i’m able to load xml and can view objects.

just that, i failed to build a script logic which will match computer initials with region & country code in xml and get values of custom setting meant for that country.

Figured out…it wasnt difficult though

$XmlDocument.data.record | where {$_.Countrycode -eq $ComCountry}