无法在以管理员身份运行的 PowerShell 中访问网络驱动器 [英] Cannot access network drive in PowerShell running as administrator

查看:149
本文介绍了无法在以管理员身份运行的 PowerShell 中访问网络驱动器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Windows 7 x64 虚拟机中运行 PowerShell.我在映射为网络驱动器 (Z:) 的主机上有一个共享文件夹.当我正常运行 PS 时,我可以很好地访问该驱动器,但是如果我以管理员身份"运行它,它会告诉我:

I'm running PowerShell in a Windows 7 x64 virtual machine. I have a shared folder on the host mapped as a network drive (Z:). When I run PS normally I can access that drive just fine, but if I run it "as administrator" it tells me:

Set-Location : Cannot find drive. A drive with the name 'Z' does not exist.
At line:1 char:13
+ Set-Location <<<<  Z:
    + CategoryInfo          : ObjectNotFound: (Z:String) [Set-Location], DriveNotFoundException
    + FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.SetLocationCommand

我如何以管理员身份访问网络驱动器?

How do I access network drives as administrator?

推荐答案

最后的修复只是重新映射驱动器号同时以管理员身份运行:

In the end the fix was simply to re-map the drive letter while running as Administrator:

net use Z: "\\vmware-host\Shared Folders"

不必从同一个 PowerShell 实例(或根本不需要从 PowerShell)执行此操作 - 只需在整个登录会话中执行一次即可.

It doesn't have to be done from the same PowerShell instance (or from PowerShell at all) - it's just something that needs to be done once for the entire logon session.

这篇关于无法在以管理员身份运行的 PowerShell 中访问网络驱动器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆