Powershell中显示隐藏文件的方法

支持PS3.0及以后版本。
当你使用 Get-ChildItem 检索文件,默认是不显示隐藏文件的。
要包含隐藏文件,请使用 –Force 参数。

PS> Get-ChildItem -Path $home -Force

如果只需要显示隐藏文件,可以使用参数-Hidden ,但它只支持PS3.0。

PS> Get-ChildItem -Path $home -Hidden

    Directory: C:UsersTobias

Mode                LastWriteTime     Length Name                                                             
----                -------------     ------ ----                                                             
d--h-        08.01.2012     10:38            AppData                                                          
d--hs        08.01.2012     10:38            Application Data                                                 
d--hs        08.01.2012     10:38            Cookies                                                          
d--hs        08.01.2012     10:38            Local Settings                                                   
d--hs        08.01.2012     10:38            My Documents                                                     
d--hs        08.01.2012     10:38            NetHood                                                          
(...)