Evaluating Parenthesized Boolean Expressions

by Apr 27, 2012

Hey all,

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!