Get-ChildItem
Use Get-ChildItem to get the items and child items in one or more specified locations.
Documentation: Microsoft Learn — Get-ChildItem
Syntax
See the command anatomy
Inspect this authored example with fictional data in the bounded browser model. The numbered stages show how its objects change.
Get-ChildItem [[-Path] <string[]>] [[-Filter] <string>] [-Include <String[]>] [-Exclude <String[]>] [-Recurse] [-Depth <UInt32>] [-Force] [-Name] [<CommonParameters>]- Stage 1Get-ChildItem
-Path -Filter -Include -Exclude -Recurse -Depth -Force -Name
Try it
Browser simulation · fictional data; no changes to your computer.
Follow the objects
Run the command to inspect each stage.
Examples
Get-ChildItem -File
Show reference output
Illustrative output · values vary by environment
Name Length Extension ---------- -------- --------- app.log 12582912 .log readme.txt 2048 .txt errors.log 26214400 .log trace.log 524288 .log
Get-ChildItem -Filter *.log
Show reference output
Illustrative output · values vary by environment
Mode LastWriteTime Length Name ----- ----------------- ------ ---------- -a--- 9/10/2026 8:41 PM 4096 app.log
List all with Get-ChildItem
Show reference output
Illustrative output · values vary by environment
Name Length Extension ---------- -------- --------- app.log 12582912 .log readme.txt 2048 .txt errors.log 26214400 .log trace.log 524288 .log
Parameters
Parameter definitions:
-Path-Filter-Include-Exclude-Recurse-Depth-Force-Name
Practical use and troubleshooting
Practical scenario: Use Get-ChildItem when you need to get the items and child items in one or more specified locations. Review syntax and sample output, then try an example in the browser lab. Start with one identified target and inspect the returned values before extending the operation to a list. Keep the identity in your report so you can trace each result back to the object or path that produced it.
Common error and fix: Access denied during recursion can leave an incomplete inventory. Record inaccessible paths, use an appropriate account and do not label the result complete when some directories could not be read. In an unattended script, capture this failure with its original error record and record which target failed. An empty result and an unsuccessful query must remain distinguishable in the final report.
See also: Get-Item. Get-ChildItem enumerates children of a container; Get-Item returns the item at the path itself. Use the appropriate scope when a report must list files rather than describe its root directory. Read the linked command before substituting it; similar names do not imply identical inputs or output.
Put this command to work
Find large log files
Return Name and Length for .log files larger than 10,000,000 bytes.
The sandbox is visible now. Sign in with Google only when you run or check a task; commands and temporary files are discarded when you leave.
Run a command to inspect its result.
Inspect starting data
Supported syntax
Virtual files
Recap
Get-ChildItem Use Get-ChildItem to get the items and child items in one or more specified locations.
Next: Get-Content