解决 PowerShell 的 "You don't currently have permission to access this folder" 问题

Working around the "You don't currently have permission to access this folder" issue for PowerShell

在 Windows 2008 R2 服务器上以管理员身份导航到 C:\Users\%SomeUsername% 时,我收到错误 You don't currently have permission to access this folderClick Continue to permanently get access to this folder。单击 Continue 可解决此问题。

如果我通过 PowerShell 尝试相同的操作(例如 get-childitem 'C:\Users\' -Directory | get-childitem -Force;或某些变体),我尚未授予自己访问权限的任何配置文件都会明确给出错误 Access to the path 'C:\Users\%SomeUsername%' is denied.;即使包含 Force 开关。

有没有办法通过 PowerShell "click continue";即让系统允许我访问任何我没有严格访问权限的东西,尽管作为服务器上的管理员可以授予我自己访问权限。理想情况下,这将在我访问文件时完成(例如,通过 Get-Item 命令上的开关),而不是必须编写一些代码来显式地通过所有文件检查和修改权限。

我的错误;我没有以管理员身份 运行 连接 PowerShell 会话(即 UAC)。

  • 右键单击 powershell.exe
  • 运行 作为管理员

确保以管理员身份启动 Powershell 运行 如果你想总是 运行 它以管理员身份从 powershell.exe 创建快捷方式并按照此图像操作: