Created
October 20, 2016 17:38
-
-
Save sheldonhull/dbbc8356028264047fd742b56c5ee27e to your computer and use it in GitHub Desktop.
Basic Setting of Variables from JSON object via powershell that's dynamic
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
#get json content (should not be nested, just flat file of variables) | |
$json = Get-Content -Raw -Path ([io.path]::Combine($Path,"settings.json")) -force | ConvertFrom-Json | |
#get list of variable in collection available | |
[string[]]$variables = ($json | get-member -Name * -MemberType NoteProperty).Name | |
#iterate through each variable name and get the value from the json object | |
foreach ($v in $variables) | |
{ | |
Set-Variable -name $v -value ($json.$v) -Force -Verbose | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment