【发布时间】:2020-08-02 19:12:16
【问题描述】:
我的 powershell 脚本有问题,我正在尝试递归查找文件夹中的文件。我正在查找的文件夹是 %temp%。不幸的是,在这个文件夹中,有一些受管理员权限保护的文件夹。然后当我使用 Get-ChildItem 时,它除了错误(UnauthorizedAccessException)之外什么都不返回。
这是我的代码:
$path= (Get-ChildItem -path $ENV:TEMP -force -Recurse -Include logMyApp.txt).FullName
我也尝试了 -ErrorAction SilentlyContinue,但它不起作用。
感谢您的宝贵时间:)
编辑:试图打个招呼,但它不起作用,stackoverflow 策略?
【问题讨论】:
-
使用
-Filter代替-Include然后再次尝试使用-ErrorAction SilentlyContinue:) -
@MathiasR.Jessen Omg 你为我节省了很多时间!谢谢!
-
我认为拒绝访问部分并不重要。
标签: powershell access-denied get-childitem