Created
April 4, 2013 14:07
-
-
Save sunnyc7/5310649 to your computer and use it in GitHub Desktop.
Convert Web.Config to a hashtable. Use Keys to get the values.
This file contains 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
<# | |
web.config.xml | |
<configuration> | |
<applicationSettings> | |
<add key="machineName" value="Prod" /> | |
<add key="anotherMachineName" value="Test" /> | |
<add key="EnvTypeDefault" value="Dev" /> | |
<add key="RootURLProd" value="http://domain.com/app/" /> | |
<add key="RootURLTest" value="http://test.domain.com/app/" /> | |
<add key="RootURLDev" value="http://localhost/app/" /> | |
<add key="HumanReadableEnvTypeProd" value="" /> | |
<add key="HumanReadableEnvTypeTest" value="Test Mode" /> | |
<add key="HumanReadableEnvTypeDev" value="Development Mode" /> | |
</applicationSettings> | |
</configuration> | |
#> | |
[xml]$webconf = Get-Content 'web.config.xml' | |
$x = $webconf.configuration.applicationSettings.add | |
$hash = @{} | |
foreach ($y in $x) { | |
$hash.Add($y.key,$y.Value) | |
} | |
$hash.machineName |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment