If Statement Against Dynamic Variable [duplicate]
问题 This question already has answers here : Calling dynamic variable in PowerShell (2 answers) Closed last year . 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