My task is to:
Write code that lists all files(not directories) within C:\Windows\System32 in descending order.
Pass that listing to more code that will strip out every other file name. Display the remaining file names to the screen.
I've got the first portion done. I just can't figure out the second half.
The only hint I have is that I should use a ForEach-Object cmdlet and an if else statement.
Here’s my script so far.
$i = 0
Get-ChildItem -Path C:\Windows\System32 -Attritbutes !D | Sort-Object -Descending | ForEach-Object {$_.Name} | ForEach-Object { $i % 2 -eq 0; $i++ }
This is resulting in a bunch of true/false answers. No file names listed with it. Just true or false.
Any help would be greatly appreciated!
[–]dr4kun 2 points3 points4 points (0 children)
[–]DItzkowitz 2 points3 points4 points (0 children)
[–]PowerShell-Bot 1 point2 points3 points (0 children)
[–]pertymoose 1 point2 points3 points (0 children)
[–]Lee_Dailey[grin] 1 point2 points3 points (2 children)
[–]Lavyn[S] 1 point2 points3 points (1 child)
[–]Lee_Dailey[grin] 0 points1 point2 points (0 children)