要递归搜索隐藏文件,我正在使用:
gci -Path C:\ -Filter part_of_filename* -Recurse -Force | where { $_.Attributes -match "Hidden"}
输出显示了很多错误,具体如下所示(取决于路径):
Get-ChildItem:拒绝访问路径“ C:\ Documents and Settings”。在C:\ Users \ USERNAME \ Documents \ powershell \ searchdisk.ps1:10 char:5 + gci <<<< -Path C:\ -Filter part_of_filename * -Recurse -Force | 其中{$ _。Attributes -match“ Hidden”} + CategoryInfo:PermissionDenied:(C:\ Documents and Settings:String)[Get-ChildItem],UnauthorizedAccessException + FullyQualifiedErrorId:DirUnauthorizedAccessError,Microsoft.PowerShell.Commands.GetChildItemCommand
我需要一个PowerShell命令,该命令以递归方式搜索ANY目录(包括隐藏目录),并向我显示所有文件,包括名称为part_of_filename *的隐藏文件(对于此示例)
我使用PowerShell ISE作为管理员运行了命令。它不会在目录之类的目录中搜索
C:\ Windows \ System32 \ LogFiles \ WMI \ RtBackup
您做对了。只需在高架控制台中运行它并卸下过滤器即可。如果您不关心权限错误,请附加-ErrorAction SilentlyContinue
:
Get-ChildItem -Path C:\ -Filter lush* -Recurse -Force `
-ErrorAction SilentlyContinue
Directory: C:\
Mode LastWriteTime Length Name
---- ------------- ------ ----
-arhs 25.09.2013 12:16 1208 lush.asx
lush.asx
具有ReadOnly,Hidden和System属性。
您可能还希望通过管道来| select Name, Length, Directory
摆脱那条不幸的Directory: C:\
路。DirectoryName
如果您想要不带文件名的完整路径,则还有一个。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句