无法在 Powershell 远程会话中访问 UNC 路径 [英] Unable to access UNC Paths in Powershell remote session

查看:28
本文介绍了无法在 Powershell 远程会话中访问 UNC 路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法在本地计算机的 Powershell 远程会话中访问服务器上的 UNC 路径.我可以直接从 Servers Cmd 提示中使用它们.

I am unable to access the UNC paths on my servers in a Powershell remote session from my local machine. I am able to use them from Servers Cmd prompt directly.

实际上,我已经登录到服务器并将一个 UNC 路径映射为本地驱动器(比如 X:).使用登录时重新连接"选项.

Actually, I have logged into the server and mapped a UNC path as local drive (say X:). Used Reconnect on Login option.

我有一个批处理文件驻留在这个 X: 驱动器中,我想使用本地脚本中的 invoke 命令远程运行它.但是,它失败了.

I have a batch file which resides in this X: drive, I want to run it remotely using invoke command from my local script. But, it fails.

它说找不到驱动器.名称为 X 的驱动器不存在".

It says "Cannot find drive. A drive with name X doesn't exist".

此外,当我尝试在脚本块中使用 net use 命令映射驱动器时,它也会引发错误 - 系统错误 1223 - 本机命令错误.

Also, when I try to map drive using net use command in the scriptblock then also it throws an error - System error 1223 - Native Command Error.

我使用管理员凭据登录此服务器.

I use administrator credentials to log into this server.

任何人都可以帮我解决这个问题吗,我想做的就是远程运行驻留在此 UNC 路径上的脚本?

Can anyone please help me on this, all i want to do is to run the script remotely which resides on this UNC path ?

另外,当我将服务器中的 UNC 路径映射为本地驱动器时,为什么我无法在 PS 远程会话中使用它?

Also, when I map a UNC Path in the server as a local drive, why am I unable to use it in a PS remote session ?

提前致谢.TS

推荐答案

这里确实有 3 种不同的情况.

You've really got 3 different things going on here.

1 &3. 驱动器仅在交互登录时映射.因此,当您远程访问另一台计算机,映射驱动器,然后注销/断开连接时,该映射驱动器已断开连接.除了在交互式 GUI 用户会话中,您不能依赖不是您自己创建的映射驱动器号.在脚本或任何远程会话中,只需对所有内容使用 UNC 路径 - 这样更可靠.

1 & 3. Drives are only mapped when you log on interactively. So when you remoted into the other computer, mapped a drive, and then logged off/disconnected, that mapped drive was disconnected. Except in interactive GUI user sessions, you cannot depend upon a mapped drive letter that you don't create yourself. Within scripts or any remote session, just use UNC paths for everything - it's more reliable.

2.当您尝试在远程 PS 会话中映射驱动器时,您会遇到所谓的双跳"问题.有一个解决方案,但您必须进行额外的设置.请参阅双跳访问复制文件而无需 CredSSP

2 . When you attempt to map the drive in the remote PS session, you're encountering what's known as the "double hop" problem. There is a solution to this, but there's extra setup you have to do. See Double hop access to copy files without CredSSP

这篇关于无法在 Powershell 远程会话中访问 UNC 路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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