- 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 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.
- Related Articles
- How to list the directory content in Linux?
- How to install the PowerShell Active Directory module?
- How to retrieve the content of the file in PowerShell?
- How to clear the content of the recycle bin in PowerShell?
- How to create bulk users in the active directory using PowerShell?
- How to install MSI file to the custom directory using PowerShell?
- Java Program to get the content of a directory
- How to display a directory list in HTML?
- How to list directory tree structure in python?
- How to list the hidden files in a directory in Java?
- How to delete the Organizational Unit (OU) from the active directory using PowerShell?
- How to list all files in a directory using Java?
- How to get the list of jpg files in a directory in Java?
- What is Get-Content in PowerShell used for?
- How to list the Azure VMs using Azure CLI in PowerShell?

Advertisements