PowerShell Logo Small

Get-ChildItem



This is the built-in help made by Microsoft for the command 'Get-ChildItem', in PowerShell version 2 - as retrieved from Windows version 'Microsoft® Windows Vista™ Ultimate ' 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 items and child items in one or more specified locations.

SYNTAX


Get-ChildItem [[-Path] <string[]>] [[-Filter] <string>] [-Exclude <string[]>] [-Force] [-Include <string[]>] [-Name] [-Recurse] [-UseTransaction]
[<CommonParameters>]
Get-ChildItem [-LiteralPath] <string[]> [[-Filter] <string>] [-Exclude <string[]>] [-Force] [-Include <string[]>] [-Name] [-Recurse] [-UseTransac
tion] [<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, k
nown 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 another provider, such as a registry hive or a certificat
e store.



<

RELATED LINKS

Online version: http://go.microsoft.com/fwlink/?LinkID=113308
about_Providers
Get-Item
Get-Alias
Get-Location
Get-Process

REMARKS

<

Examples


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

C:\PS>get-childitem



Description
-----------
This command gets the child items in the current location. If the location is a file system directory, it gets the files and sub-directories in t
he current directory. If the item does not have child items, this command returns to the command prompt without displaying anything.

The default display lists the mode (attributes), last write time, file size (length), and the name of the file. The valid values for mode are d (
directory), a (archive), r (read-only), h (hidden), and s (system).








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

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



Description
-----------
This command retrieves all of the .txt files in the current directory and its subdirectories. The dot (.) represents the current directory and th
e Include parameter specifies the file name extension. The Recurse parameter directs Windows PowerShell to retrieve objects recursively, and it i
ndicates that the subject of the command is the specified directory and its contents. The force parameter adds hidden files to the display.








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

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



Description
-----------
This command lists 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 contents of the Logs subdirectory, not the directory container. Because the command does not include the Recurse parameter, G
et-ChildItem does not include the content of directory automatically; you need to specify it.








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

C:\PS>get-childitem registry::hklm\software



Description
-----------
This command retrieves all of the registry keys in the HKEY_LOCAL_MACHINE\SOFTWARE key in the registry of the local computer.








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

C:\PS>get-childitem -name



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








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

C:\PS>get-childitem cert:\. -recurse -codesigningcert



Description
-----------
This command gets all of the certificates in the certificate store that have code-signing authority.

The command uses the Get-ChildItem cmdlet. The path specifies the Cert: drive exposed by the Windows PowerShell certificate provider. The backsla
sh (\) symbol specifies a subdirectory of the certificate store and the dot (.) represents the current directory, which would be the root directo
ry of the certificate store. The Recurse parameter specifies a recursive search.

The CodeSigningCertificate parameter is a dynamic parameter that gets only certificates with code-signing authority. For more information, type "
get-help certificate".








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

C:\PS>get-childitem * -include *.exe



Description
-----------
This command retrieves all of the items in the current directory with a ".exe" file name extension. The wildcard character (*) represents the con
tents of the current directory (not the container). When using the Include parameter without the Recurse parameter, the path must point to conten
ts, not a container.