Powershell Command : Get-ChildItem

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 :

-Exclude<String[]>

It was used to exclude the items.

-LiteralPath<String>

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.

-Filter<String>

Use to filter to get specific items.

-Force

This command was used to get the hidden files or system files.

-Include<String[]>

Used to include specific items.

-Name

Used to get the names of the items.

-Path<String[]>

Used to specify a path to a location.

-Recurse

Used to get all the child items in a location.

-UseTransaction

Include the command in the active transaction.

CommonParameters:

-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

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *