(不是为了替代 Vogelpoel & Chaganti 的工作,而是作为对 CredSSP.cs 的快速阅读的快速总结,因此您可以快速了解它在做什么——也就是说,它在我的几个系统上进行了测试手头有,似乎工作)
function Get-WSManCredSSPState
{
$res = [pscustomobject]@{DelegateTo = @(); ReceiveFromRemote = $false}
$wsmTypes = [ordered]@{}
(gcm Get-WSManCredSSP).ImplementingType.Assembly.ExportedTypes `
| %{$wsmTypes[$_.Name] = $_}
$wmc = new-object $wsmTypes.WSManClass.FullName
$wms = $wsmTypes.IWSManEx.GetMethod('CreateSession').Invoke($wmc, @($null,0,$null))
$cli = $wsmTypes.IWSManSession.GetMethod('Get').Invoke($wms, @("winrm/config/client/auth", 0))
$res.ReceiveFromRemote = [bool]([xml]$cli).Auth.CredSSP
$afcPath = 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\CredentialsDelegation\AllowFreshCredentials'
if (test-path $afcPath)
{
$afc = gi $afcPath
$res.DelegateTo = $afc.GetValueNames() | sls '^\d+$' | %{$afc.GetValue($_)}
}
return $res
}