- 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 retrieve specific file(s) information using Get-ChildItem in PowerShell?
When the item (file) path is provided to the Get-ChildItem cmdlet, it extracts the file information like Name, LastWriteTime, Size, etc.
Example
Get-ChildItem -Path D:\Temp\style.css
Output
Directory: D:\Temp Mode LastWriteTime Length Name ---- ------------- ------ ---- -a---- 08-12-2017 10:16 393 style.css
Command
To get the full properties of the file then you need to use fl * (Format-List *) pipeline command.
Get-ChildItem -Path D:\Temp\style.css | fl *
Output
PSPath : Microsoft.PowerShell.Core\FileSystem::D:\Temp\style.css PSParentPath : Microsoft.PowerShell.Core\FileSystem::D:\Temp PSChildName : style.css PSDrive : D PSProvider : Microsoft.PowerShell.Core\FileSystem PSIsContainer : False Mode : -a---- VersionInfo : File: D:\Temp\style.css InternalName: OriginalFilename: FileVersion: FileDescription: Product: ProductVersion: Debug: False Patched: False PreRelease: False PrivateBuild: False SpecialBuild: False Language: BaseName : style Target : {} LinkType : Name : style.css Length : 393 DirectoryName : D:\Temp Directory : D:\Temp IsReadOnly : False Exists : True FullName : D:\Temp\style.css Extension : .css CreationTime : 08-12-2017 10:02:17 CreationTimeUtc : 08-12-2017 04:32:17 LastAccessTime : 08-12-2017 10:02:17 LastAccessTimeUtc : 08-12-2017 04:32:17 LastWriteTime : 08-12-2017 10:16:26 LastWriteTimeUtc : 08-12-2017 04:46:26 Attributes : Archive
Command
You can get the specific properties by pipelining the Select-Object parameter. From the above example, we will display the File Name, attributes, extension, creation time, last access time and last write time.
Get-ChildItem D:\Temp\style.css | Select Name, Extension, CreationTime, LastAccessTime, LastWriteTime
Output
Name : style.css Extension : .css CreationTime : 08-12-2017 10:02:17 LastAccessTime : 08-12-2017 10:02:17 LastWriteTime : 08-12-2017 10:16:26
Similarly, you can retrieve multiple files information in the same command. Each filename needs to be separated by comma (,).
PS D:\Temp> Get-ChildItem .\style.css, .\cars.xml
- Related Articles
- How to exclude specific file names using Get-ChildItem in PowerShell?
- How to search for a specific extension using Get-ChildItem in PowerShell?
- How to exclude specific extension in Get-ChildItem in PowerShell?
- How to use Get-ChildItem in PowerShell to filter a specific extension?
- How to get the specific process(es) information using PowerShell?
- How to get the readonly files using Get-ChildItem in PowerShell?
- How to retrieve CSV file headers using PowerShell?
- How to get the system files using the Get-ChildItem in PowerShell?
- How to list the subfolder contents using Get-ChildItem using PowerShell?
- How to use the -recursive parameter in Get-ChildItem using PowerShell?
- How to control recursion in Get-ChildItem in PowerShell?
- How to use Depth pararmeter in Get-ChildItem PowerShell?
- How to get only files but not the folders with Get-ChildItem using PowerShell?
- How to get the disk information using PowerShell?
- How to use the wildcard character (*) in Get-ChildItem in PowerShell?

Advertisements