PowerTip: Display Hidden Files by Using PowerShell

Summary: Learn how to display hidden files by using Windows PowerShell.

Hey, Scripting Guy! Question How can I use Windows PowerShell to display hidden files?

Hey, Scripting Guy! Answer Use the Force parameter for Get-Childitem (or the aliases dirls or gci):

dir -Force -File

Comments (5)

  1. mredwilson says:

    @K you are correct. This will in fact filter out only the hidden files. Great catch. Thanks for sharing.

  2. k says:

    gci -force | ?{$_.mode -match "h"}

  3. Jesse Heines says:

    As of March 5, 2014, the -file parameter returns an error:

    C:2014sigcseGitHubWorkshopproject1 [master +1 ~0 -0 !]> dir -force -file
    Get-ChildItem : A parameter cannot be found that matches parameter name ‘file’.
    At line:1 char:17
    + dir -force -file < <<<
    + CategoryInfo : InvalidArgument: (:) [Get-ChildItem], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand

  4. Sean says:

    Try ls -h

  5. Greg Lambert says:

    -file and -Directory were added in Version 3

Skip to main content