Contact Info

Crumbtrail » Administration » Powershell » Powershell 1.0 » Get-ChildItem

Get-ChildItem - Powershell 1.0 CmdLet

ActiveXperts Network Monitor ships with integrated Powershell scripts to monitor complex network. The scripts run out of the box
Download the ActiveXperts Network Monitor FREE version now »


Get child items (contents of a folder or registry key)

Get-ChildItem [[[-path]| [-literalPath] ]string[]] [[-filter] string]
         [-include string[]]  [-exclude string[]] [-name] [-recurse]
            [-force] [CommonParameters]

-path string
       The paths to the items from which content is to be retrieved.
       Wildcards are permitted.

   -literalPath string
       Like Path above, only the value is used exactly as typed.
       No characters are interpreted as wildcards. If the path includes any
       escape characters then enclose the path in single quotation marks.
   -include string
       Include only the specified items from the Path. e.g. "May*"
   -exclude string
       Omit the specified items from the Path e.g. "*SS64*"
       This parameter does not work properly in this cmdlet.
   -filter string
       A filter in the provider's format or language. 
       The exact syntax of the filter (wildcard support etc) depends on the provider.
       Filters are more efficient than -include/-exclude, because the provider
       applies the filter when retrieving the objects, rather than having 
       PowerShell filter the objects after they are retrieved.
       Retrieve only the names of the items.
       This is useful when piping the names of the child items to another command.
       Get the items plus all child items of the location(s).
       Only for paths that point to a container such as C:\Windows or C:\Windows\*
       A path such as *.txt will not have any child items.

       Override restrictions that prevent the command from succeeding, apart
       from security settings. e.g. Force will create file path directories 
       or override a files read-only attribute, but will not change file permissions.
       Retrieve only certificates that have code signing authority. 
       Valid only when using the Windows PowerShell Certificate provider.
       For more info, type "get-help about_provider" and "get-help about_signing".

       -Verbose, -Debug,-ErrorAction,-ErrorVariable, -OutVariable.

Get the child items in the current location:

PS C:\>get-childitem

List all the .XLS files in C:\Work and all sub-folders:

PS C:\>get-childitem C:\Work\ -Include *.xls -Recurse

List all the files owned by BillG:

PS C:\>get-childitem C:\Work\ -recurse | get-acl | where {$_.Owner -match "BillG"}

Measure the size of a folder:

Get-ChildItem C:\Work\ -Recurse -Force | Measure-Object -property length -sum

Get all the certificates in the certificate store that have a code-signing authority:

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

You can also run gci against a file share on a remote machine using a UNC path.