Skip to content

XML powershell

Featured Replies

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

 

 

Join the conversation

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

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.