dimanche 18 novembre 2018

Powershell, If Statement Against Dynamic Variable

I am attempting to do something similar to the following ...

New-Variable -Name "state_$name" -Value "True"
if ("state_$name" -eq "True") {
Write-Host "Pass" } else { Write-Host "Fail" }

I have attempted this a number of different ways but it is not working exactly how I would like it to work. I need to write the if statement to account for a dynamic variable as these values will change inside of a foreach loop.

I have provided a simple example above for proof of concept.

Aucun commentaire:

Enregistrer un commentaire