【问题标题】:Is there an easy way to check if CredSSP is enabled on a systems?是否有一种简单的方法可以检查系统上是否启用了 CredSSP?
【发布时间】:2013-09-28 22:28:53
【问题描述】:

我知道Get-WSManCredSSP 函数;但是,此 cmdlet 在脚本中不能正常工作。这将返回一个类似于以下内容的长字符串:

The machine is configured to allow delegating fresh credentials to the following target(s): wsman/*,wsman/*,wsman/*,wsman/*
This computer is configured to receive credentials from a remote client computer.

我不能轻易地将它包含在我正在编写的脚本中,因此我正在寻找另一种方法来检查 CredSSP。

【问题讨论】:

    标签: windows powershell windows-server wsman


    【解决方案1】:

    您是否可以考虑按照CmdLet help 中的说明使用它:获取客户端上的 WS-Management CredSSP 设置 (<localhost|computername>\Client\Auth\CredSSP)。

    在本地机器上它给出:

    (Get-Item  WSMan:\localhost\Client\Auth\CredSSP).value
    

    你可以这样使用它:

    (Get-Item  WSMan:\localhost\Client\Auth\CredSSP).value -eq $false
    

    你可以先测试一下WinRm是否可用:

    (Get-Service -Name winrm ).Status
    

    【讨论】:

    • 值得注意的是,这是针对客户端启用的 CredSSP。如果要检查服务器启用的 CredSSP,请使用以下命令:(Get-Item WSMan:\localhost\Service\Auth\CredSSP).value
    【解决方案2】:

    我还在为 Get-WSManCredSSP 输出的限制而苦苦挣扎,发现 Victor Vogelpoel/Ravikanth Chaganti 的 this helper script 真的很有帮助。

    一些例子:

    检查当前机器是否已配置为 CredSSP 服务器和/或客户端:

    (Get-WSManCredSSPConfiguration).IsServer
    (Get-WSManCredSSPConfiguration).IsClient
    

    检查是否已为指定的客户端计算机设置了委派:

    Get-WSManCredSSPConfiguration | % { $_.ClientDelegateComputer.Contains('clientcomputername') }
    

    【讨论】:

      【解决方案3】:

      (不是为了替代 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
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-06-29
        • 1970-01-01
        • 1970-01-01
        • 2019-10-08
        • 2015-10-14
        • 2020-03-12
        • 1970-01-01
        • 2012-02-26
        相关资源
        最近更新 更多