"Bob Landau" <BobLandau@xxxxxx> wrote in message
news:8AB72523-4133-4912-AAC5-CA4D2A109F41@xxxxxx
....
Quote:
> Here is another example using Get-ChildItem; say I'd like to find all
> files
> that have their archive and read-only bit set and order these by Creation
> time and then by name. For CMDs "dir" its done this way
>
> dir c:\junk /aar-d /o-dn /tc
>
> however to do the same thing for GCI you need a longer line even if you do
> use the shortcut aliases
>
> gci "c:\junk" | % { $attr = $( $_.get_Attributes() ); if ( -not ( (
> $attr
> -bxor 33 ) -band 33 ) -and -not ( $attr -band 16 ) ) { $_} } | Sort
> @{e={$_.CreationTime}; Descending=$true}, @{e={$_.Name}; Ascending=$true}
>
> 33 is ReadOnly | Achive and 16 is directory I used the values rather than
> the constants to shorten up the line.
>
> In both of these cases most people would prefer to use simpler, older
> method.
Not to disqualify your overall comment, but you should be aware of how you
can simplify the above command:
dir c:\junk | where {$_.attributes -eq 33} | sort
@{e={$_.creationtime};desc=$true}, name
Jacques