9.6. Using the get-content Cmdlet

The get-content cmdlet returns the content of a specified item at a specified location. You are likely to have aliases available to use the get-content cmdlet, for example cat, type, and gc. If you are unsure which aliases are available on your system use, the following command to find out:

get-alias |
where-object {$_.definition -eq "get-content"}

NOTE

The Windows PowerShell help files occasionally differ in completeness or accuracy from the actual implementation of a cmdlet. A useful technique to find the current functionality is to use the definition property. For example, to retrieve the information for the get-content cmdlet, use this command: (get-commandget-content).definition.

The get-content cmdlet supports the following parameters, in addition to the common parameters.

  • Path — Specifies the path to the item or file that data is to be retrieved from.

  • Readcount — Specifies how many lines are to be sent through the pipeline at a time. The default value is 0 (all lines).

  • Totalcount — Specifies the number of elements (often lines) to retrieve from the target file or item. The default value is −1 (retrieve all lines).

  • Filter — Specifies filter elements as required and supported by providers.

  • Include — Specifies which container's items are to be retrieved. The value of this parameter qualifies the value of the -path parameter.

  • Exclude — Specifies which container's items are not to be retrieved. The value of this parameter qualifies the value of ...

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

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.