Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

mapping - Unable to access UNC Paths in Powershell remote session

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.

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

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.

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

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.

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

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 ?

Thanks in Advance. TS

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

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 . 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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...