- 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 list the directory content in PowerShell?
To display the directory content, Get-ChildItem cmdlet is used. You need to provide the path of the directory or if you are in the same directory, you need to use only Get-ChildItem directly. In the below example, we need to display the contents of the D:\temp directory.
When Get-ChildItem command is run outside of this directory then the path of the directory should be provided. This is called the absolute path.
PS C:\> Get-ChildItem D:\Temp\
Command
When this command is run directly within the directory then simply run this command. This is called a relative path.
PS D:\Temp> Get-ChildItem
Output
Directory: D:\Temp Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 13-12-2019 09:52 GPO_backup d----- 24-11-2018 11:31 LGPO -a---- 07-05-2018 23:00 301 cars.xml -a---- 29-12-2017 15:16 4526 healthcheck.html -a---- 29-12-2017 15:16 4526 healthcheck1.html -a---- 08-12-2017 10:24 48362 servicereport.html -a---- 08-12-2017 10:24 48362 servicereport1.html -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 -a---- 12-12-2017 23:04 1034 testhtmoutput.html
Please note − Get-ChildItem command only displays the folders and files but not the content of the subfolders. To display the subfolders and their files, you need to use –Recursive parameter.
Advertisements
To Continue Learning Please Login
Login with Google