Подтвердить что ты не робот

Удаленное управление Powershell - политика не позволяет делегировать учетные данные пользователя

Я новичок в powershell, и у меня возникают проблемы с использованием делегирования полномочий. У меня есть следующий script:

$session = New-PSSession myserver -Authentication CredSSP -Credential DOMAIN\Administrator
Invoke-Command -Session $session -ScriptBlock { <Some PowerShell Command> }

Перед запуском, я сделал следующее:

  • Запустите Enable-PSRemoting на сервере myserver.
  • Запустите Enable-WSManCredSSP Server на myserver.
  • Запустите Restart-Service WinRM на сервере myserver.
  • Запустите Enable-WSManCredSSP Client –DelegateComputer myserver на клиенте.
  • Перезагрузите сервер и клиент.

Но как только я запустил script, я получаю следующее сообщение об ошибке:

[myserver] Connecting to remote server failed with the following error message : The WinRM client cannot process the request. A computer policy does not allow the delegation of
 the user credentials to the target computer. Use gpedit.msc and look at the following policy: Computer Configuration -> Administrative Templates -> System -> Credentials Delega
tion -> Allow Delegating Fresh Credentials.  Verify that it is enabled and configured with an SPN appropriate for the target computer. For example, for a target computer name "m
yserver.domain.com", the SPN can be one of the following: WSMAN/myserver.domain.com or WSMAN/*.domain.com. For more information, see the about_Remote_Troubleshooting Help topic.
    + CategoryInfo          : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [], PSRemotingTransportException
    + FullyQualifiedErrorId : PSSessionOpenFailed

Я проверил политики, упомянутые в сообщении об ошибке, но все кажется прекрасным. Что еще может блокировать меня?

4b9b3361

Ответ 1

Наконец-то я получил его для работы благодаря этой странице. Он предоставляет script, который устанавливает необходимые политики делегирования учетных данных, напрямую устанавливая соответствующие ключи реестра. Как только я запустил этот script с правами администратора, я смог успешно установить подключение CredSSP к myserver:

Enable-WSManCredSSP -Role client -DelegateComputer *.mydomain.com

$allowed = @('WSMAN/*.mydomain.com')

$key = 'hklm:\SOFTWARE\Policies\Microsoft\Windows\CredentialsDelegation'
if (!(Test-Path $key)) {
    md $key
}
New-ItemProperty -Path $key -Name AllowFreshCredentials -Value 1 -PropertyType Dword -Force            

$key = Join-Path $key 'AllowFreshCredentials'
if (!(Test-Path $key)) {
    md $key
}
$i = 1
$allowed |% {
    # Script does not take into account existing entries in this key
    New-ItemProperty -Path $key -Name $i -Value $_ -PropertyType String -Force
    $i++
}

Ответ 2

Мне нужно было сделать следующее на сервере:

Enable-WSManCredSSP -Role Server

Мне нужно было сделать следующее на клиенте:

set-item wsman:localhost\client\trustedhosts -value *

Enable-WSManCredSSP -Role Client –DelegateComputer *

Используйте gpedit.msc на клиенте, чтобы включить делегирование свежих учетных данных в WSMAN/*:

  • Разверните Local Computer Policy, разверните Computer Configuration, разверните Administrative Templates, разверните System, а затем нажмите Credential Delegation.
  • В области Settings дважды щелкните Allow Delegating Fresh Credentials with NTLM-only Server Authentication.
  • В диалоговом окне Allow Delegating Fresh Credentials with NTLM-only Server Authentication сделайте следующее:
  • Нажмите Enabled.
  • В области Options нажмите Show.
  • В поле Значение введите WSMAN/*, а затем нажмите OK. Убедись, что Concatenate OS defaults with input above, а затем нажмите OK.

Следующая команда теперь работает (после запроса пароля):

Invoke-Command { dir \\fileserver\devtools } -computer appserver01 -authentication credssp -credential domain\user

См. Форумы MSDN.

См. TechNet

Ответ 3

Развернувшись на ответ Akira выше, в gpedit.msc мне нужно было установить "Разрешить делегирование свежих учетных данных с помощью проверки подлинности только NTLM", а не "Разрешить делегирование свежих учетных данных".