Created
September 22, 2015 19:08
-
-
Save techthoughts2/84c8fbf7a196d94315a7 to your computer and use it in GitHub Desktop.
Import settings from an XML file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.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 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment