- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to get only folders but not the files in the Get-ChildItem in PowerShell?
To get only folders excluding files, we need to use –Attribute parameter with Directory attribute.
Command
Get-ChildItem D:\Temp\ -Attributes Directory
Output
Directory: D:\Temp Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 13-12-2019 09:52 GPO_backup d----- 24-11-2018 11:31 LGPO
Similarly, you can combine different operations.
To get the only system directories, use the below command.
Get-ChildItem D:\Temp\ -Attributes Directory –System -Recurse
To get the system directories that are hidden.
Get-ChildItem D:\Temp\ -Attributes Directory -Recurse –System -Hidden
To get the system directories which are Readonly.
Get-ChildItem D:\Temp\ -Attributes Directory -Recurse –System -Readonly
- Related Articles
- How to get only files but not the folders with Get-ChildItem using PowerShell?
- How to get only hidden files and folders in PowerShell?
- How to get the readonly files using Get-ChildItem in PowerShell?
- How to get the system files using the Get-ChildItem in PowerShell?
- How to get hidden files and folders using PowerShell?
- How to display files/folders including hidden files/folders in PowerShell?
- How to use the wildcard character (*) in Get-ChildItem in PowerShell?
- How to control recursion in Get-ChildItem in PowerShell?
- How to use the -recursive parameter in Get-ChildItem using PowerShell?
- How to use Depth pararmeter in Get-ChildItem PowerShell?
- How to exclude specific extension in Get-ChildItem in PowerShell?
- How to get the list of shared folders using PowerShell?
- How to get the list of empty folders using PowerShell?
- What is Get-ChildItem cmdlet in PowerShell?
- How to copy files/folders to the remote location in the PowerShell?

Advertisements