If you google for PowerShell Eqv you currently will find the VBScript-to-Windows PowerShell Conversion Guide on top of the list. Yet the answer is much of technical help:
Eqv Operator
Definition: Performs a logical equivalence on two expressions.
No doubt Eqv has its uses; we’re just not sure if it has any practical uses. Although there might be a Windows PowerShell equivalent we have to be honest: we didn’t look real hard for one.
In fact, I used the Eqv
operator (also written as: A↔B
) a number of times in VBScript and likely would have used it in PowerShell if it existed.
Example
I have a list of groups ("HR", "SAP", "!IT", "..."
). If a user is a member of all the listed groups and explicitly not a member of groups that are preceded with an escalation mark (like "!IT"
, which is unraveled to: $Negate = $True
and $Group = "IT"
) a specific task should be done. The script needs to iterate through the groups and immediately break the iteration when a group condition is not met (to save time).
A command for this would have been something like:
If ($Negate -eqv (IsMember($Group))) {Break}
How can I build a logical equivalence operator with a minimum of code?