使用服务帐户访问被拒绝

Access is denied using a service account

我在 MachineB 的远程 MachineA 上尝试 运行 一些 NLB 命令,但在使用服务帐户时出现访问被拒绝错误。当我 运行 作为我的帐户时,命令 运行 没问题。

最初,当 运行ning 从我的本地计算机发出命令时,我也无法 运行 命令。我遇到了同样的错误。即使我能够执行 Enter-PSSession 和 运行 简单命令。但是在遵循这个 guide 之后,我能够为我的帐户解决它。这是一个双跳问题。

现在我不知道为什么服务帐户不会执行这些命令。

$userName = "domain\account"
$Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $userName, $password
$Session = New-PSSession -ComputerName MachineA -Credential $Credential -Authentication Credssp
Invoke-Command -Session $Session -ScriptBlock { 
    
    Import-Module NetworkLoadBalancingClusters
    Get-NLBClusterNode MachineA
    } 
}

Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
    + CategoryInfo          : PermissionDenied: (Microsoft.Netwo...tNlbClusterNode:GetNlbClusterNode) [Get-NlbCl 
   usterNode], UnauthorizedAccessException
    + FullyQualifiedErrorId : AccessDenied,Microsoft.NetworkLoadBalancingClusters.PowerShell.GetNlbClusterNode
    + PSComputerName        : ComputerName

附加信息: 服务帐户是机器上的管理员。我在事件日志中没有看到任何错误。当服务帐户登录时,我在事件日志中看到

 Detailed Authentication Information:
                         Logon Process:        Kerberos
                         Authentication Package:    Kerberos
                         Transited Services:    -
                         Package Name (NTLM only):    -
                         Key Length:        0

当我执行 Get-WSMANCredSSP 时,它会给我以下输出。这允许我使用我的个人帐户执行调用命令。

    PS C:\Windows\system32> Get-WSManCredSSP
    The machine is configured to allow delegating fresh credentials to the following target(s): wsman/machinenameB
    ,wsman/fullyqualifiedmachinenameB,wsman/machinenameB
This computer is configured to receive credentials from a remote client computer

附加信息: 我发现帐户类型是活动目录用户和计算机工具中的用户。用户属性上没有委派选项卡。这可能是个问题吗?

问题是用户不是我们 NLB 环境中的一个 clusterNodes 的管理员。在执行 NLB 时我没有仔细注意的是,当您使用 PowerShell 远程访问任何 clusterNode 时,该帐户必须是所有节点上的管理员,即使您没有远程访问其他服务器也是如此。因此,虽然该帐户在一台服务器上是管理员,但它不在其中一台服务器上,因此它因此错误而失败。