How to List Files Only in PowerShell

How to List Files Only in PowerShell

Postby admin » Tue May 10, 2016 1:59 pm

Issue:
How do I show a list of files only in PowerShell ? I use the get-childitem cmdlet but it shows files AND directories.
admin
Site Admin
 
Posts: 106
Joined: Mon Jan 18, 2010 11:05 am

Re: How to List Files Only in PowerShell

Postby admin » Tue May 10, 2016 2:09 pm

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".
admin
Site Admin
 
Posts: 106
Joined: Mon Jan 18, 2010 11:05 am


Return to Powershell

Who is online

Users browsing this forum: No registered users and 1 guest

cron