
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Exclude Specific Extension in Get-ChildItem in PowerShell
To exclude specific extensions, you need to use –Exclude parameter in Get-ChildItem.
Example
For example, as shown below when we run command, it will exclude .html files and display the rest.
Get-ChildItem D:\Temp\ -Recurse -Exclude *.html
Output
Directory: D:\Temp Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 24-11-2018 11:31 LGPO Directory: D:\Temp\LGPO Mode LastWriteTime Length Name ---- ------------- ------ ---- -a---- 01-06-2017 03:22 410088 LGPO.exe -a---- 01-06-2017 02:25 638115 LGPO.pdf Directory: D:\Temp Mode LastWriteTime Length Name ---- ------------- ------ ---- -a---- 07-05-2018 23:00 301 cars.xml -a---- 08-12-2017 10:16 393 style.css -a---- 08-12-2017 11:29 7974 Test.xlsx -a---- 25-10-2017 08:13 104 testcsv.csv
You can exclude multiple extensions as well.
Example
In the below example, we will exclude html and xml extensions.
Get-ChildItem D:\Temp\ -Recurse -Exclude *.html,*.xml
Output
Directory: D:\Temp Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 24-11-2018 11:31 LGPO Directory: D:\Temp\LGPO Mode LastWriteTime Length Name ---- ------------- ------ ---- -a---- 01-06-2017 03:22 410088 LGPO.exe -a---- 01-06-2017 02:25 638115 LGPO.pdf Directory: D:\Temp Mode LastWriteTime Length Name ---- ------------- ------ ---- -a---- 08-12-2017 10:16 393 style.css -a---- 08-12-2017 11:29 7974 Test.xlsx -a---- 25-10-2017 08:13 104 testcsv.csv
Advertisements