Parsing XML and apply settings for PCs

Welcome Forums General PowerShell Q&A Parsing XML and apply settings for PCs

This topic contains 5 replies, has 3 voices, and was last updated by

 
Participant
3 months, 1 week ago.

  • Author
    Posts
  • #107905

    Participant
    Points: 0
    Rank: Member

    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

  • #107918

    Participant
    Points: 160
    Helping Hand
    Rank: Participant

    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.

  • #107920

    Participant
    Points: 0
    Rank: Member

    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.

  • #107923
    js

    Participant
    Points: 213
    Helping Hand
    Rank: Participant

    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')
  • #107992

    Participant
    Points: 0
    Rank: Member

    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.

  • #107995

    Participant
    Points: 0
    Rank: Member

    Figured out....it wasnt difficult  though

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

The topic ‘Parsing XML and apply settings for PCs’ is closed to new replies.