techthoughts2
9/22/2015 - 7:08 PM

Import settings from an XML file

Import settings from an XML file

<#
.Synopsis
   Get-Config function will pull in needed data from config file
.DESCRIPTION
   Get-Config function will pull in needed data from config file.
#>
function Get-Config {
	#specify the location of the config file
	$csv = Import-Clixml -Path "C:\HypQC_Config.xml"
	#Read the XML config file and load data into variables
	try{
		$Script:accountNumber = $csv.Account
		$Script:dc = $csv.Datacenter
		$Script:hostname = $csv.HostName
		$Script:primaryIP = $csv.PrimaryIP
		$Script:pNetMask = $csv.PrimaryNetMask
		$Script:pgateway = $csv.PrimaryGateway
		$Script:dns1 = $csv.DNS1
		$Script:dns2 = $csv.DNS2
		$Script:serviceNetIP = $csv.ServiceNetIP
		$Script:serviceNetMask = $csv.ServiceNetMask
		$Script:serviceGateway = $csv.ServicenetGateway
		$Script:PubMacs = $csv.PubMacs
		$Script:SNetMac = $csv.SNetMac
		#check for any null values and halt if any found
		Test-Nulls
	}
	catch{
		Write-Host "ERROR - Config file properties could not be read. This is MOST LIKELY due to an empty field in the config file. Re-check the config file and try again." -ForegroundColor Red
		Exit
	}
}