Powershell Command : Get-ChildItem
It was used to get the items in one or more locations.
Get-ChildItem Description :
The Get-Childitem cmdlet was used to get specific items through the powershell or it can also be used to browse the directories. That location could be a directory, a sub-directory, a registry location. This is one of the most useful command in the powershell which will be used frequently by the programmers.
Get-ChildItem Syntax :
Parameter Set: Items Get-ChildItem [[-Path] <String> ] [[-Filter] <String> ] [-Exclude <String> ] [-Force] [-Include <String> ] [-Name] [-Recurse] [-UseTransaction] [ <CommonParameters>] Parameter Set: LiteralItems Get-ChildItem [[-Filter] <String> ] -LiteralPath <String> [-Exclude <String> ] [-Force] [-Include <String> ] [-Name] [-Recurse] [-UseTransaction] [ <CommonParameters>]
Get-ChildItem Parameters :
It was used to exclude the items.
It was used to specify the path to the location, the class which we are specifying as the literalpath parameter is used exactly as it is typed.
Use to filter to get specific items.
This command was used to get the hidden files or system files.
Used to include specific items.
Used to get the names of the items.
Used to specify a path to a location.
Used to get all the child items in a location.
Include the command in the active transaction.
-Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, -OutVariable.
Get-ChildItem Examples :
1) This command is used to list files in the directories.
PS C:> Get-ChildItem
2) This command is used to list the files in its directories and its sub directories with the extension “.txt”
PS C:> Get-ChildItem –Path *.txt -Recurse -Force
3) This command gets the registry key in the specified registry location.
PS C:> Get-ChildItem –Path HKLM:Software