我试图做一个脚本,列出提取文件夹和子文件夹以及特定目录路径的文件数。如何排除其访问在脚本中被拒绝的文件夹?
我使用了get-childitem代码片段和where {$_.permission -match "read",我不知道我正在尝试的内容是否正确。最后出现了以下错误:message:
Microsoft.PowerShell.Commands.GetChildItemCommand : CategoryInfo : ReadError:(\support.-242\新文件夹:String)
发布于 2014-04-16 20:28:06
您可以按cmdlet设置错误操作首选项,如下所示:
Get-ChildItem -recurse -ErrorAction SilentlyContinue | ? {$_.permission -match "read"}也可以使用系统变量将其设置为每个脚本:
$ErrorActionPreference = "SilentlyContinue"
Get-Help about_CommonParameters
https://stackoverflow.com/questions/23119010
复制相似问题