use*_*132 5 powershell powershell-2.0 powershell-3.0
我试图做一个脚本来列出提取文件夹和子文件夹以及特定目录路径的文件数.如何排除脚本中拒绝访问的文件夹?
我使用了get-childitem
代码片段where {$_.permission -match "read"
,我不知道我正在尝试的是否正确.我最终得到以下错误:消息:
CategoryInfo:ReadError:(\ support ....- 242\New folder:String)[Get-ChildItem],IOException + FullyQualifiedErrorId:DirIOError,Microsoft.PowerShell.Commands.GetChildItemCommand
您可以为每个cmdlet设置错误操作首选项,如:
Get-ChildItem -recurse -ErrorAction SilentlyContinue | ? {$_.permission -match "read"}
Run Code Online (Sandbox Code Playgroud)
或者您可以使用System变量为每个脚本设置它:
$ErrorActionPreference = "SilentlyContinue"
Get-Help about_CommonParameters
归档时间: |
|
查看次数: |
5417 次 |
最近记录: |