Confused with -Include parameter of the Get-ChildItem cmdlet

后端 未结 6 1641

From documentation:

-Include

Retrieves only the specified items. The value of this parameter qualifies the Path parameter. Enter a pa

6条回答
  •  星月不相逢
    2020-12-06 18:09

    I just asked a similar question and got three quick replies concerning the Get-Help for Get-ChildItem.

    The answer is in the full description of the command (Get-Help Get-ChildItem -full):

    The Include parameter is effective only when the command includes the
    

    Recurse parameter or the path leads to the contents of a directory, such as C:\Windows*, where the wildcard character specifies the contents of the C:\Windows directory.

    So the following would work without recurse.

    PS C:\foo> Get-childitem -path "c:\foo*" -Include *.txt

    From Stack Overflow question PowerShell Scripting - Get-ChildItem.

    I hope this helps :-)

提交回复
热议问题