PowerShell Logo Small

Get-ChildItem



This is the built-in help made by Microsoft for the command 'Get-ChildItem', in PowerShell version 4 - as retrieved from Windows version 'Microsoft Windows 8.1 Enterprise' PowerShell help files on 2016-06-23.

For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.

SYNOPSIS

Gets the files and folders in a file system drive.

SYNTAX


Get-ChildItem [[-Path] <String[]>] [[-Filter] <String>] [-Exclude <String[]>] [-Force] [-Include <String[]>] [-Name] [-Recurse] [-UseTransaction [<SwitchParameter>]]
[<CommonParameters>]
Get-ChildItem [[-Filter] <String>] [-Exclude <String[]>] [-Force] [-Include <String[]>] [-Name] [-Recurse] -LiteralPath <String[]> [-UseTransaction [<SwitchParameter>
]] [<CommonParameters>]
Get-ChildItem [-Attributes <FileAttributes]>] [-Directory] [-File] [-Force] [-Hidden] [-ReadOnly] [-System] [-UseTransaction] [<CommonParameters>]



Search powershellhelp.space

DESCRIPTION


The Get-ChildItem cmdlet gets the items in one or more specified locations. If the item is a container, it gets the items inside the container, known as child items.
You can use the Recurse parameter to get items in all child containers.


A location can be a file system location, such as a directory, or a location exposed by a different Windows PowerShell provider, such as a registry hive or a certific
ate store.

In a file system drive, the Get-ChildItem cmdlet gets the directories, subdirectories, and files. In a file system directory, it gets subdirectories and files.

By default, Get-ChildItem gets non-hidden items, but you can use the Directory, File, Hidden, ReadOnly, and System parameters to get only items with these attributes.
To create a complex attribute search, use the Attributes parameter. If you use these parameters, Get-ChildItem gets only the items that meet all search conditions, a
s though the parameters were connected by an AND operator.

Note: This custom cmdlet help file explains how the Get-ChildItem cmdlet works in a file system drive. For information about the Get-ChildItem cmdlet in all drives, t
ype "Get-Help Get-ChildItem -Path $null" or see Get-ChildItem at http://go.microsoft.com/fwlink/?LinkID=113308.



<

RELATED LINKS

Online version: http://technet.microsoft.com/library/hh847897(v=wps.630).aspx
Get-ChildItem
(generic); http://go.microsoft.com/fwlink/?LinkID=113308
FileSystem Provider
Clear-Content
Get-Content
Get-ChildItem
Get-Content
Get-Item
Remove-Item
Set-Content
Test-Path

REMARKS

<

Examples


-------------------------- EXAMPLE 1 --------------------------

C:\PS>Get-ChildItem



Description

-----------

This command gets the files and subdirectories in the current directory. If the current directory does not have child items, the command does not return any results.








-------------------------- EXAMPLE 2 --------------------------

C:\PS>Get-Childitem -System -File -Recurse



Description

-----------

This command gets system files in the current directory and its subdirectories.








-------------------------- EXAMPLE 3 --------------------------

C:\PS>Get-ChildItem -Attributes !Directory,!Directory+Hidden

C:\PS> dir -att !d,!d+h



Description

-----------

These command get all files, including hidden files, in the current directory, but exclude subdirectories. The second command uses aliases and abbreviations, but has
the same effect as the first.








-------------------------- EXAMPLE 4 --------------------------

C:\PS>dir -ad



Description

-----------

This command gets the subdirectories in the current directory. It uses the "dir" alias of the Get-ChildItem cmdlet and the "ad" alias of the Directory parameter.








-------------------------- EXAMPLE 5 --------------------------

C:\PS>Get-ChildItem -File -Attributes !ReadOnly -path C:\ps-test



Description

-----------

This command gets read-write files in the C:\ps-test directory.








-------------------------- EXAMPLE 6 --------------------------

C:\PS>get-childitem . -include *.txt -recurse -force



Description

-----------

This command gets all of the .txt files in the current directory and its subdirectories.

The dot (.) represents the current directory. The Include parameter specifies the file name extension. The Recurse parameter directs Windows PowerShell to search for
objects recursively, and it indicates that the subject of the command is the specified directory and its contents. The Force parameter adds hidden files to the displa
y.








-------------------------- EXAMPLE 7 --------------------------

C:\PS>get-childitem c:\windows\logs\* -include *.txt -exclude A*



Description

-----------

This command gets the .txt files in the Logs subdirectory, except for those whose names start with the letter A. It uses the wildcard character (*) to indicate the co
ntents of the Logs subdirectory, not the directory container. Because the command does not include the Recurse parameter, Get-ChildItem does not include the contents
of the current directory automatically; you need to specify it.








-------------------------- EXAMPLE 8 --------------------------

C:\PS>get-childitem -name



Description

-----------

This command retrieves only the names of items in the current directory.