Created
July 23, 2019 08:05
-
-
Save TomasBouda/ac139d4e6a5c7f5dd69a4f773920906e to your computer and use it in GitHub Desktop.
Dynamicaly create powershell variable
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
# config.json | |
#{ | |
# "variables": [ | |
# { | |
# "name": "basePath", | |
# "value": "C:\\inetpub\\approot" | |
# } | |
# ], | |
# "test": "$basePath\\test" | |
#} | |
#----------- | |
$config = Get-Content $jsonConfigPath | ConvertFrom-Json | |
foreach($var in $config.variables){ | |
New-Variable -Name $var.name -Value $var.value -Force -Option ReadOnly | |
} | |
$pathToTest = $ExecutionContext.InvokeCommand.ExpandString($config.test) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment