FreeKB - PowerShell Get-ChildItem command (search find a file or directory)
PowerShell - Get-ChildItem command (search find a file or directory)

The Get-ChildItem command without any options will list the files and directories in the present working directory.

> Get-ChildItem

    Directory: C:\Users\john.doe

Mode                LastWriteTime         Length Name                                                                                                                    
----                -------------         ------ ----                                                                                                                                                                                                                              
d-----        3/26/2021   4:02 AM                foo                                                                                                                     
-a---l        3/26/2021   4:02 AM                bar.txt

 

The -recurse flag can be used to list the files and directories below the present working directory.

> Get-ChildItem -recurse

 

Sometimes, permission denied will be returned at certain sub directories. The -erroraction silentlycontinue option can be used to ignore such errors.

> Get-ChildItem -recurse -erroraction silentlycontinue

 

The -path option can be used to specify the base directory to search from.

> Get-ChildItem -path C:\ -recurse

 

The -file flag can be used to only display files.

> Get-ChildItem -file

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter 7aa59 in the box below so that we can be sure you are a human.




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |