If you find yourself needing binary or bitwise operations, PowerShell has the requisite operators as shown in Table 6.4:
Operator | Definition |
---|---|
-band | binary and |
-bor | binary or |
-bnot | binary not |
The underlying binary math is beyond the scope of this book. However, here are some examples if you need to perform a bitwise comparison:
PS C:\> 255 -band 255 255 PS C:\> 255 -band 150 150 PS C:\> 32 -bor 16 48 PS C:\>
In each case the value that is returned from the comparison is the digital equivalent of the underlying bitwise operation.