How to List Files Only in PowerShell
Posted:
Tue May 10, 2016 1:59 pm
by admin
Issue:
How do I show a list of files only in PowerShell ? I use the get-childitem cmdlet but it shows files AND directories.
Re: How to List Files Only in PowerShell
Posted:
Tue May 10, 2016 2:09 pm
by admin
Solution:
In PowerShell, you can do this in different ways.
However, I have figured out how to do it using the following method. It involves piping the output of get-childitem into where-object. So the syntax goes like this :
get-childitem "c:\" | where-object { $_.Mode -ne "d----" }
Consequently, if you want to display directories only, you can change the conditional operator from "-ne" to "-eq".