0
votes

I have a VDI setup in Azure and have users in two regions however I need to create a login script, ideally in PowerShell

The login script will update users' environment variables. Now the tricky part, I will need this script to pull the information from a file, JSON or Excel. Ideally a JSON file.

I want it to check for the heading of Variable name and Variable value from the JSON file.

Now depending on the region of the virtual server, I would want only variables updated for the user if they are in North East and have a set of variables for users in South Coast

1
So.. are you asking us to write the JSON file for you? - Theo
I am asking, how does the powershell script look for this - how do I create a ps script to pull or use the JSON File - Jude Clermont
@JudeClermont - how to use JSON? you use your fave search engine to look for powershell use json. [grin] - Lee_Dailey

1 Answers

0
votes

If you are trying to load a file from the local file system :

You can load the content into the memory and then convert it to custom object to do further manipulation.

$text = Get-content "<YOUR PATH TO THE JSON FILE>\<FILENAME>.json"
$json = $text | ConvertFrom-Json

If your JSON File is present in an endpoint or so. You can do a invoke-webrequest

$response = Invoke-WebRequest "https://yourendpoint.com/filename.json"
$content = $response.Content
$json = $content | ConvertFrom-Json

Sample output / Sample Usage : enter image description here