Jump to content


  • 0
conorofarrell

XML powershell

Question

Hi

I am looking for a good way to run a script in powershell, to detect my site from an XML. We are currently using MDT to do this, but we cannot be completely automated due to the fact that we often build our machines on a central site and ship them out. This this end, I am putting together an XML file to pull the default settings as below. I'm happy with the 2nd (locale)section and how I can use it, I'm not sure how to approach the first section, pulling the gateway out and assigning the 3 letter site code. We have a lot of subnets of each site, so if I can list all the subnets, then assign the site code, that's how I would do it.

My XML file:

<?xml version="1.0" encoding="iso-8859-1"?>
<Settings>
	<DefaultGateway>
		<10.10.14.1>
			<Site>DUB></SITE>
		</10.10.14.1>
		<10.10.15.1>
			<Site>"DUB"</Site>
		</10.10.15.1>
		<10.10.16.1>
			<Site>MUC</Site>
		</10.10.16.1>
		<10.10.17.1>
			<Site>MUC</MUN>
		</10.10.17.1>
	</DefaultGateway>
	
	<Locale>
		<DUB>
			<TimeZoneName>GMT Standard Time</TimeZoneName>
			<KeyboardLocale>en-IE</KeyboardLocale>
			<InputLocale>1809:00001809</InputLocale>
			<UserLocale>en-IE</UserLocale>
			<UILanguage>en-US</UILanguage>
			<CountryCode>353</CountryCode>
			<SystemLocale>en-IE</SystemLocale>
		</DUB>
		<MUC>
			<TimeZoneName>W. Europe Standard Time</TimeZoneName>
			<KeyboardLocale>de-DE</KeyboardLocale>
			<InputLocale>0407:00000407</InputLocale>
			<UserLocale>de-DE</UserLocale>
			<UILanguage>de-DE</UILanguage>
			<CountryCode>49</CountryCode>
			<SystemLocale>de-DE</SystemLocale>
		</MUC>
	</Locale>
</Settings>

This is my Powershell script. Obviously, I've trimmed it back to just echo the results od the OSDSystemLocale to the console before creating my full-on Task Sequence script:

[xml]$ConfigFile = Get-Content "c:\temp\Settings.xml"

$IPConfig = Get-WmiObject -Class Win32_NetworkAdapterConfiguration
$DEFGateway = '10.10.14.1'

$DefaultGateway = @{
    OSDSite = $Configfile.Settings.DefaultGateway.$DEFGateway.Site
    }

$LocaleSettings = @{
    OSDSite = $Configfile.Settings.Location.$SITE.Site
    OSDTimeZoneName = $Configfile.Settings.Location.$SITE.TimeZoneName
    OSDKeyboardLocale = $Configfile.Settings.Location.$SITE.KeyboardLocale
    OSDInputLocale = $Configfile.Settings.Location.$SITE.InputLocale
    OSDUserLocale = $Configfile.Settings.Location.$SITE.UserLocale
    OSDUILanguage = $Configfile.Settings.Location.$SITE.UILanguage
    OSDCountryCode = $Configfile.Settings.Location.$SITE.CountryCode
    OSDSystemLocale = $Configfile.Settings.Location.$SITE.SystemLocale
    }


	Write-Host $LocaleSettings.OSDSystemLocale

Any tips on how I could/should do this? I'm deliberately trying to avoid the MDT database, due to the amount of manual changes we end up performing on it. I have a feeling I may end up falling back on it for the site detection at least. I'm just trying to automate as much as I can, but still give the tech a time limited option with a posh script to select an alternative site.

 

Thanks

Con

 

 

Share this post


Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.