Author Posts

August 8, 2018 at 3:07 pm

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

August 8, 2018 at 3:51 pm

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.

August 8, 2018 at 4:13 pm

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 🙂

have mentioned xml code in original post.

August 8, 2018 at 4:34 pm

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')

August 8, 2018 at 5:58 pm

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.

August 8, 2018 at 6:33 pm

Figured out....it wasnt difficult  though

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