简体   繁体   English

执行GCI时出现System.UnauthorizedAccessException

[英]System.UnauthorizedAccessException when doing a GCI

I have a script and am getting a System.UnauthorizedAccessException on this command: 我有一个脚本,并且正在此命令上获取System.UnauthorizedAccessException:

gci "\\Media\\recorded tv\" -include *.* -Recurse

I can access the directory from Windows Explorer. 我可以从Windows资源管理器访问该目录。 When I run the script in PS, I get most of the files, but a few of those errors. 当我在PS中运行脚本时,我得到了大多数文件,但其中一些错误。

Things I tried: 1) Made sure execution policy was set from elevated (as admin) Powershell 2) Made sure ran PS as admin 我尝试的操作:1)确保从提升权限(以管理员身份)PowerShell设置了执行策略2)确保以管理员身份运行PS

If these files are for some reason not accessible, how can I find out which files are not accessible? 如果这些文件由于某种原因无法访问,我如何找出哪些文件无法访问? Maybe they are hidden/system files? 也许它们是隐藏的/系统文件?

It's possible that individual files/directories have different permissions. 单个文件/目录可能具有不同的权限。 Check the security settings on the items Get-ChildItem writes errors about. 检查项目的安全设置, Get-ChildItem写入有关错误的信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM