Collections:
Other Resources:
Get Directory Entries in Windows PowerShell
How to get a list of files in a directory in Windows PowerShell? Can I use the old "dir" command?
✍: FYIcenter.com
Yes, you can still use the old "dir" command in Windows PowerShell.
But "dir" is defined as an alias of the "Get-ChildItem" cmdlet.
The "Get-ChildItem" cmdlet gets the items in the current directory by default. "Get-ChildItem" cmdlet returns child items as an array of FileInfo objects. You can pipe them into other cmdlets.
For example, the following command gets first 5 files from the C:\Windows directory:
PS C:\fyicenter> Get-ChildItem C:\Windows -File | Select-Object -First 5
Directory: C:\Windows
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 9/4/2007 4:14 PM 180000 aaRemove.exe
-a--- 11/20/2010 7:16 AM 65024 bfsvc.exe
-a--- 1/4/2012 12:04 PM 124789 DirectX.log
-a--- 1/5/2012 1:22 AM 1774 DtcInstall.log
-a--- 2/25/2011 12:30 AM 2616320 explorer.exe
Here are some example on how to use "Get-ChildItem" cmdlet:
"`n--- Get files and subdirectories recursively ---" Get-ChildItem -Recurse "`n--- Get files only ---" Get-ChildItem -File "`n--- Get subdirectories only ---" Get-ChildItem -Directory "`n--- Get system files including hidden ones ---" Get-ChildItem C:\Windows\System32 -Force
⇒ Create Directory in Windows PowerShell
⇐ Get and Change Directory in Windows PowerShell
2016-10-24, ∼3837🔥, 0💬
Popular Posts:
What is "Pml Driver HPZ12" in my Windows 7 service list? And how is "Pml Driver HPZ12" service relat...
What is "Protexis Licensing V2" in my Windows 7 service list? And how is "Protexis Licensing V2" ser...
What is "IKE and AuthIP IPsec Keying Modules" in my Windows XP service list? And how is "IKE and Aut...
How do I move the licenses for the songs that I purchased from an online store to my new computer? T...
How to start and stop a Windows XP service? If you want to start or stop a Windows service, you can ...