本文提供了远程桌面服务(RDS)客户端无法连接到远程桌面(RD)会话主机服务器的问题的解决方案。
原始 KB 数: 2844958
重要
本文包含有关如何修改注册表的信息。 修改注册表之前,一定要先对其进行备份。 并且一定要知道在发生问题时如何还原注册表。 有关如何备份、还原和修改注册表的详细信息,请单击以下文章编号以查看Microsoft知识库中的文章:322756 如何备份和还原 Windows 中的注册表
现象
请考虑以下方案:
- 在 Windows Server 2012 中设置 RDS 的标准部署。 部署包含 RD 会话主机服务器、RD 连接代理服务器和 RD Web 访问服务器。
- 创建一个会话集合,该集合可由 RDS 客户端通过 RD Web Access 网站访问。
- 会话集合中所有 RD 会话主机服务器的 IP 地址已更改。
在此方案中,RDS 客户端无法连接到会话集合,在连接期间会收到以下错误消息:
凭据不起作用。
原因
出现此问题的原因是以下子项中已过时的注册表项:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\ClusterSettings
**SessionDirectoryRedirectionIP**注册表项存储创建 RDS 部署时分配的 RD 会话主机服务器的 IP 地址。 尽管 RD 会话主机服务器的 IP 地址已更改,但 RD 连接代理设置中的 IP 地址不会更新。 因此 RDS 客户端无法连接到会话集合。
解决方法
警告
如果使用注册表编辑器或使用其他方法错误地修改了注册表,则可能会发生严重问题。 这些问题可能需要重新安装操作系统才能解决。 Microsoft 不能保证可以解决这些问题。 您应自行承担修改注册表的风险。
若要解决此问题,请从会话集合中的每个 RD 会话主机服务器中删除 SessionDirectoryRedirectionIP 以下注册表子项的注册表项:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\ClusterSettings
或者,可以运行以下 PowerShell 脚本。 此脚本从部署中的每个 RD 会话主机服务器中删除注册表项。
Import-Module RemoteDesktop
# Delete the Registry Key for all machine name specified in $RemoteMachine
Function DeleteRegistryKey($RemoteMachine)
{
$reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $RemoteMachine)
# connect to the needed key :
$regKey= $reg.OpenSubKey("System\\CurrentControlSet\\Control\\Terminal Server\\ClusterSettings", $true )
# and delete the SessionDirectoryRedirectionIP subkey, if it exists
foreach ($key in $regKey.GetValueNames())
{
if ($key -eq "SessionDirectoryRedirectionIP")
{
$regKey.DeleteValue($key)
Write-Host "Machine : "$RemoteMachine
}
}
}
# Get the list of collections on the machine
$RdSessionCollections = Get-RDSessionCollection
if ($RdSessioncollections -eq $null)
{
Write-Host "No RDSH Session Collections"
return
}
foreach ($SessionCollection in $RdSessionCollections)
{
Write-Host "Collection Name : " $SessionCollection.CollectionName
# get list of RDSH Servers in the collection
$RdSessionHosts = Get-SessionHost -CollectionName $SessionCollection.CollectionName
foreach ($SessionHost in $RdSessionHosts)
{
Write-Host "SessionHost : "$SessionHost.SessionHost
# Delete the regkey on this server
DeleteRegistryKey($SessionHost.SessionHost)
}
}