How to Show Hidden Files in PowerShell (With Examples)


You can use the Dir statement in PowerShell to display all files in the current directory:

Dir

If you would like to display all files including hidden files, then you can use the -Force parameter:

Dir -Force

And if you would like to display only the hidden files, then you can use the -Hidden parameter:

Dir -Hidden

The following example shows how to use each of these methods in practice.

Example: How to Show Hidden Files in PowerShell

We can use the Dir statement to view all files in our current directory:

Dir

The following screenshot shows how to use this syntax in practice:

This returns a total of four files in our current directory.

If we would like to display all files in the current directory including hidden files then we can use the following syntax:

Dir -Force

The following screenshot shows how to use this syntax in practice:

PowerShell show hidden files

Notice that this returns a total of six files, which means there were two hidden files in the current directory.

To display only the hidden files, we can use the following syntax:

Dir -Hidden

The following screenshot shows how to use this syntax in practice:

PowerShell display only hidden files

Notice that this returns only the two files in the current directory that were hidden.

Related Tutorials

The following tutorials explain how to perform other common tasks in PowerShell:

PowerShell: How to Use Test-Path to Check Multiple Paths
PowerShell: How to Get File Name from Path
PowerShell: How to Get Last Folder in Path

Leave a Reply