How to get only hidden files and folders in PowerShell?

PowerShellMicrosoft TechnologiesSoftware & Coding

To display only hidden files and folders –hidden parameter is used while using Get-ChildItem.

Command

Get-ChildItem D:\Temp\ -Hidden

Output

PS C:\WINDOWS\system32> Get-ChildItem D:\Temp\ -Hidden
    Directory: D:\Temp
Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a-h--       13-12-2019     09:52           6182 Hiddenfile1.xlsx

Command

Similarly, you can use this –Hidden with –Recurse or

–Depth

Get-ChildItem D:\Temp\ -Recurse -Hidden

Output

PS C:\WINDOWS\system32> Get-ChildItem D:\Temp\ -Recurse -Hidden
    Directory: D:\Temp
Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a-h--       13-12-2019     09:52           6182 Hiddenfile1.xlsx
    Directory: D:\Temp\GPO_backup
Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a-h--       13-12-2019     09:52              0 HiddenFile2.txt
raja
Published on 23-Jan-2020 07:38:59
Advertisements