![]() NAME Get-ChildItem SYNOPSIS Gets the items and child items in one or more specified locations. SYNTAX Get-ChildItem [[-Path] ] [-Recurse] [-UseTransaction] [ Get-ChildItem [-LiteralPath] -Name] [-Recurse] [-UseTransaction] [ 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 cont ainers. 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 certificate store. PARAMETERS -Exclude Omits the specified items. The value of this parameter qualifies the Path parameter. Enter a path element or pa ttern, such as "*.txt". Wildcards are permitted. Required? false Position? named Default value Accept pipeline input? false Accept wildcard characters? false -Filter Specifies a filter in the provider's format or language. The value of this parameter qualifies the Path paramet er. The syntax of the filter, including the use of wildcards, depends on the provider. Filters are more efficie nt than other parameters, because the provider applies them when retrieving the objects, rather than having Win dows PowerShell filter the objects after they are retrieved. Required? false Position? 2 Default value Accept pipeline input? false Accept wildcard characters? false -Force [ Allows the cmdlet to get items that cannot otherwise not be accessed by the user, such as hidden or system file s. Implementation varies from provider to provider. For more information, see about_Providers. Even using the F orce parameter, the cmdlet cannot override security restrictions. Required? false Position? named Default value Accept pipeline input? false Accept wildcard characters? false -Include Retrieves only the specified items. The value of this parameter qualifies the Path parameter. Enter a path elem ent or pattern, such as "*.txt". Wildcards are permitted. The Include parameter is effective only when the command includes the Recurse parameter or the path leads to th e contents of a directory, such as C:\Windows\*, where the wildcard character specifies the contents of the C:\ Windows directory. Required? false Position? named Default value Accept pipeline input? false Accept wildcard characters? false -LiteralPath Specifies a path to one or more locations. Unlike Path, the value of LiteralPath is used exactly as it is typed . No characters are interpreted as wildcards. If the path includes escape characters, enclose it in single quot ation marks. Single quotation marks tell Windows PowerShell not to interpret any characters as escape sequences . Required? true Position? 1 Default value Accept pipeline input? true (ByPropertyName) Accept wildcard characters? false -Name [ Retrieves only the names of the items in the locations. If you pipe the output of this command to another comma nd, only the item names are sent. Required? false Position? named Default value Accept pipeline input? false Accept wildcard characters? false -Path Specifies a path to one or more locations. Wildcards are permitted. The default location is the current directo ry (.). Required? false Position? 1 Default value Accept pipeline input? true (ByValue, ByPropertyName) Accept wildcard characters? false -Recurse [ Gets the items in the specified locations and in all child items of the locations. Recurse works only when the path points to a container that has child items, such as C:\Windows or C:\Windows\* , and not when it points to items that do not have child items, such as C:\Windows\*.exe. Required? false Position? named Default value Accept pipeline input? false Accept wildcard characters? false -UseTransaction [ Includes the command in the active transaction. This parameter is valid only when a transaction is in progress. For more information, see about_Transactions. Required? false Position? named Default value Accept pipeline input? false Accept wildcard characters? false This cmdlet supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, WarningVariable, OutBuffer and OutVariable. For more information, type, "get-help about_commonparameters". INPUTS System.String You can pipe a string that contains a path to Get-ChildItem. OUTPUTS Object. The type of object that Get-ChildItem returns is determined by the provider with which it is used. NOTES You can also refer to Get-ChildItem by its built-in aliases, "ls", "dir", and "gci". For more information, see about_Aliases. Get-ChildItem does not get hidden items by default. To get hidden items, use -Force. The Get-ChildItem cmdlet is designed to work with the data exposed by any provider. To list the providers avail able in your session, type "Get-PsProvider". For more information, see about_Providers. -------------------------- 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 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 -------------------------- 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 (.) represent s the current directory and the Include parameter specifies the file name extension. The Recurse parameter directs Windows PowerShell to retrieve objects recursively, and it indicates that the subject of the command is the specifi ed 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. I t uses the wildcard character (*) to indicate the contents of the Logs subdirectory, not the directory container. B ecause 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 -------------------------- 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 cer tificate provider. The backslash (\) symbol specifies a subdirectory of the certificate store and the dot (.) repre sents the current directory, which would be the root directory of the certificate store. The Recurse parameter spec ifies 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 ch aracter (*) represents the contents of the current directory (not the container). When using the Include parameter without the Recurse parameter, the path must point to contents, not a container. RELATED LINKS Online version: http://go.microsoft.com/fwlink/?LinkID=113308 about_Providers Get-Item Get-Alias Get-Location Get-Process |