New-PsDrive远程副本从DFS共享错误:指定的登录会话不存在 [英] New-PsDrive Remote copy from DFS share errors: A specified logon session does not exist

查看:934
本文介绍了New-PsDrive远程副本从DFS共享错误:指定的登录会话不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以要总结一下这个情况:我正在一台计算机上尝试使用 enter-pssession computername 运行powershell,然后从远程会话运行下面的逻辑:

  $ DFSPath =\\DFSpath.com
$ RDL1 = [char](1+ [char] (gdr?)[ - 1] .name)
新的PSDrive -Name $ RDL1 -PSProvider FileSystem -Root $ DFSPath -Persist -credential domain\UN
pre>

get-variable正确显示变量。但是,当我尝试使用 New-PSDrive 创建时,它给出:

  New-PSDrive:指定的登录会话不存在。它可能已经有
被终止

我看过这个: PowerShell 2.0:在远程会话期间访问Windows共享,能够让它上班。此外,我不知道如何在上面的脚本中设计它(将在多台计算机上运行)。有什么更新的吗?我使用v3 powershell。非常感谢!

解决方案

从事情看起来,您遇到了可怕的双跳。如果你只是远程到几台电脑,很容易设置双跳的修复。在您要远程的计算机上,您需要运行以下命令:

  PSRemoting 

启用WSManCredSSP服务器

然后在计算机上你想要 remote from ,您需要运行命令:

 启用-WSManCredSSP Client -DelegateComputer [< FQDN of服务器>] [*] 

代替完全限定域名,您可以将* 。这将允许您将您的凭据发送到任何计算机(可能是危险的)。



现在,您将如何将其用于脚本?有一个名为 Invoke-Command 的命令。如果您查看 Get-Help Invoke-Command -Parameter * 的参数,您将看到它需要一个 Credential 验证即可。以下是在多台计算机上运行命令的方法。

  $ MyCred = Get-Credential 
Invoke-Command -ComputerName计算机1,计算机2认证$ MyCred - 认证Credssp -ScriptBlock {Get-ChildItem $ args [0]} -ArgumentList'\\\ServerServer\Share'-ErrorAction SilentlyContinue
pre>

现在,如果你将远程处理到许多机器上,并且知道如何使用组策略。我建议设置 PSRemoting并使用组策略启用WSManCred


So to recap the situation: I am at one computer trying to run powershell using enter-pssession computername, then from the remote session, run the logic below:

$DFSPath = "\\DFSpath.com"
$RDL1 = [char](1+[char](gdr ?)[-1].name)
New-PSDrive -Name $RDL1 -PSProvider FileSystem -Root $DFSPath -Persist -credential domain\UN

The get-variable shows the variables properly. But when I try to create with New-PSDrive, it gives:

New-PSDrive : A specified logon session does not exist. It may already have
been terminated

I did look at this: PowerShell 2.0: Accessing Windows Shares during a Remote Session but wasn't able to get it to work. Also I wouldn't know how to devise it in my script above (which will be run on multiple computers). Is there anything newer? I am using v3 powershell. Thanks so much!

解决方案

From the looks of things it appears that you are experiencing the dreaded "Double-Hop". If you only what to remote to a few computers it's pretty easy to setup the "fix" for the "Double-Hop". On the computers that you want to remote to you need to run the following commands:

Enable-PSRemoting

Enable-WSManCredSSP Server

Then on the computer you want to remote from you need to run the command:

Enable-WSManCredSSP Client –DelegateComputer [<FQDN of the server>][*]

In place of the fully qualified domain name you can put a * instead. That will allow you to send your credentials to any computer (that could be dangerous).

Now how would you work this into a script? There is a command called Invoke-Command. If you look at the parameters of Get-Help Invoke-Command -Parameter *, you'll see that it take a Credential and a Authentication. Here's how you would run a command on multiple computers.

$MyCred = Get-Credential
Invoke-Command -ComputerName Computer1,Computer2 -Credential $MyCred -Authentication Credssp -ScriptBlock {Get-ChildItem $args[0]} -ArgumentList '\\Server\Share' -ErrorAction SilentlyContinue

Now if you'll be remoting onto many machines and you know how to use Group Policy. I'd recommend setting up PSRemoting and enabling WSManCred with the Group Policy.

这篇关于New-PsDrive远程副本从DFS共享错误:指定的登录会话不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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