9.4. Using the get-childitem Cmdlet

The get-psdrive cmdlet returns information about drives on a machine or that you created, and the set-location cmdlet lets you switch between various drives and between folders within drives. The get-childitem cmdlet allows you to retrieve information about the items in a folder.

NOTE

The behavior of the get-childitem cmdlet has been the subject of considerable discussion during PowerShell's development. Some users, including myself, found the semantics surprising in some situations. The behavior described in this section is that found in the final release version of PowerShell 1.0.

Windows PowerShell typically supports aliases for the get-childitem cmdlet. You can find those aliases on your machine by using the following command:

get-alias |
where-object {$_.Definition -eq "get-childitem"}

In a default install, the aliases dir, ls, and gci are likely to be available to you.

In addition to the common parameters, the get-childitem cmdlet supports the use of a number of parameters. However, since the get-childitem cmdlet can be used with a range of providers, not all of the supported parameters work with all providers. The supported parameters are:

  • path — A positional parameter, in position 1, which specifies the location relative to which the child items are to be found. If no value is supplied, the default is the current location. It cannot be used with the -literalPath parameter.

  • literalpath — A positional parameter, in position 1, whose value ...

Get Professional Windows® PowerShell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.