I'm not familiar with powershell at all and only need it for a few commands. I was hoping that someone could assist me. I have a json file named optionsConfig.json
that reads like so,
{
"test1": ["options_size", "options_connection", "options_object"],
"test2":["options_customArgs", "options_noUDP", "options_noName"]
}
In my powershell file, I have one line so far and this is to get the content of the json file.
$rawData = Get-Content -Raw -Path "optionsConfig.json" | ConvertFrom-Json
I had planned on having an environment variable on my system named test
that would have the value of test1
or test2
and from that, I would look at the elements of the list in the associated value in the json file. With these elements from the list, I would assume that they are also environment variables and I would want to get their values. ( a list comprehension in python would be perfect here).I'm a python guy so I am not quite certain how to show this in powershell but say I did env = getEnvironmentVariable(test)
and that equals test1
. I would then say something like for i in $rawData.env
return getEnvironmentVariable(i)
I pretty much want another list or new json object with the values for the assumed environment variables that we get from the original json object.
Is there a way that I can do this in powershell? It would help a lot if anyone could assist. I apologize if I wasn't clear with anything. Thanks
(edit) I see that $rawData.Get-ChildItem Env:test
does not work. Is there someone to write something like this in order to get the correct list from json file?
Also setting a new variable like so $var1 = Get-ChildItem Env.tool
and doing $rawData.$test.value
has no effect either.