PowerShell Logo Small

Get-ChildItem



This is the built-in help made by Microsoft for the command 'Get-ChildItem', in PowerShell version 5 - as retrieved from Windows version 'Microsoft Windows Server 2012 R2 Standard' 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 [<SwitchParameter>]]
[<CommonParameters>]
Get-ChildItem [[-Filter] <String>] [-Exclude <String[]>] [-Force] [-Include <String[]>] [-Name] [-Recurse] -LiteralPath <String[]> [-UseTransaction [<SwitchParameter>]]
[<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 certificate
store.



<

RELATED LINKS

Online Version: http://go.microsoft.com/fwlink/p/?linkid=290488
Get-Item
Get-Location
Get-Process
about_Providers

REMARKS

<

Examples


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

PS C:\>Get-ChildItem



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 the 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 --------------------------

PS C:\>Get-ChildItem –Path *.txt -Recurse -Force



This command gets all of the .txt files in the current directory and its subdirectories. The Recurse parameter directs Windows PowerShell to get 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 display.

To use the Recurse parameter on Windows PowerShell 2.0 and earlier versions of Windows PowerShell, the value use the Path parameter must be a container. Use the Include
parameter to specify the .txt file type. For example, Get-ChildItem –Path .\* -Include *.txt -Recurse






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

PS C:\>Get-ChildItem –Path C:\Windows\Logs\* -Include *.txt -Exclude A*



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, Get-ChildItem does not include the content of directory
automatically; you need to specify it.










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

PS C:\>Get-ChildItem –Path HKLM:\Software



This command gets all of the registry keys in the HKEY_LOCAL_MACHINE\SOFTWARE key in the registry of the local computer.










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

PS C:\>Get-ChildItem -Name



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










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

PS C:\>Import-Module Microsoft.PowerShell.Security
PS C:\>Get-ChildItem –Path Cert:\* -Recurse -CodeSigningCert



This command gets all of the certificates in the Windows PowerShell Cert: drive that have code-signing authority.

The first command imports the Microsoft.PowerShell.Security module into the session. This module includes the Certificate provider that creates the Cert: drive.

The second command uses the Get-ChildItem cmdlet. The value of the Path parameter is the Cert: drive. The Recurse parameter requests a recursive search. The
CodeSigningCertificate parameter is a dynamic parameter that the Certificate provider adds to the Get-ChildItem cmdlet. This parameter gets only certificates that have
code-signing authority.

For more information about the Certificate provider and the Cert: drive, go to http://go.microsoft.com/fwlink/?LinkID=113433 or use the Update-Help cmdlet to download the
help files for the Microsoft.PowerShell.Security module and then type "Get-Help Certificate".






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

PS C:\>Get-ChildItem –Path C:\Windows –Include *mouse* -Exclude *.png



This command gets all of the items in the C:\Windows directory and its subdirectories that have "mouse" in the file name, except for those with a .png file name extension.