I've been playing with Powershell for a few months now (if not years) and I came across, what I think is, an interesting case.
I have to evaluate a string as a boolean. For instance I am given the string "($true -and $false) -or $true" and I need to find a way so it returns $true.Also the string "($true -and $false) -or $false" would return $false.
Apparently there's a way to do it in JAVA: http://snipplr.com/view/42595/evaluating-parenthesized-boolean-expressions-using-stacks/But I'm not able to find any in Powershell.
Reason behind this is that I have to evaluate if a user is member of groups such as "user is member of (group 1 and group 2) or group 3".
I hope I'm clear enough. Thanks for your time and your help!
It's like explaining the issue on the forum makes one find the answer by himself.
I will still appreciate any input on this. It seems that the following would do the trick:
$test = '($true -and $false) -or $true'Invoke-Expression $test
well - when I try it, I get:
PSH [C:\foo]: ($true -and $false) -or $trueTrue
So it works here...