MSH>$byte = 23Exept from the nicer layout, does does basicly the same, gives you the bits that are set in a byte.
MSH>for ($i=0;$i -lt 8;$i++){if ($byte -band [math]::pow(2,$i)) {"$i Set"} else {"$i"} }
0 Set
1 Set
2 Set
3
4 Set
5
6
7
MSH>(gi .) | gm
MSH>(gi .) | gm
TypeName: System.IO.DirectoryInfo
Name MemberType Definition
---- ---------- ----------
....
....
Mode ScriptProperty System.Object Mode {get=$catr = "";
MSH>(gi .) | gm | fl
....
.....
TypeName : System.IO.DirectoryInfo
Name : Mode
MemberType : ScriptProperty
Definition : System.Object Mode {get=$catr = "";
if ( $this.Attributes -band 16 ) { $catr += "d" } else { $catr += "z" };
if ( $this.Attributes -band 32 ) { $catr += "a" } else { $catr += "-" } ;
if ( $this.Attributes -band 1 ) { $catr += "r" } else { $catr += "-" } ;
if ( $this.Attributes -band 2 ) { $catr += "h" } else { $catr += "-" } ;
if ( $this.Attributes -band 4 ) { $catr += "s" } else { $catr += "-" } ;
$catr;}
MSH>match-string "-band" *.txt
about_Comparison_operators.help.txt:148: -band bitwise and 10 -band 3 2
about_Comparison_operators.help.txt:151: When the -band is used to compare values, the compared bits must
about_where.help.txt:30: -band Bitwise and
about_where.help.txt:61: -band bitwise AND
October 2005 November 2005 December 2005 January 2006 February 2006 March 2006 April 2006 May 2006 June 2006 July 2006 August 2006 September 2006 October 2006 November 2006 December 2006