【问题标题】:Winrm not able to use dnscmd - Windows server 2012 R2 Standard serverWinrm 无法使用 dnscmd - Windows server 2012 R2 Standard server
【发布时间】:2019-11-11 13:16:21
【问题描述】:

我正在尝试通过 winrm 管理 Windows server 2012 R2 Standard 服务器。在服务器上,我想从 rsat 包中运行 dnscmd。如果我只是在 power shell 提示符下运行 dnscmd,您可以在下面看到它是成功的。但是,当我通过 winrm 远程调用它时,命令失败并显示 ERROR_ACCESS_DENIED。


PS C:\Windows\system32> dnscmd adServer /RecordDelete mycompany.com newTestRecord A /f
Deleted A record(s) at mycompany.com 
Command completed successfully.


PS C:\Windows\system32> Test-WsMan localhost
wsmid           : http://schemas.dmtf.org/wbem/wsman/identity/1/wsmanidentity.xsd
ProtocolVersion : http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd
ProductVendor   : Microsoft Corporation
ProductVersion  : OS: 0.0.0 SP: 0.0 Stack: 3.0


PS C:\Windows\system32> Invoke-Command -ComputerName localhost -ScriptBlock {
>> dnscmd adServer /RecordDelete mycompany.com newTestRecord A /f
>> } 
Command failed:  ERROR_ACCESS_DENIED     5    0x5


PS C:\Windows\system32> Invoke-Command -ComputerName localhost -ScriptBlock {
>> hostname
>> }
myServerHostname

【问题讨论】:

    标签: windows windows-server-2012-r2 winrm


    【解决方案1】:

    问题是双跳/多跳。当您通过 winRM 登录时,它不想让您使用相同的凭证令牌访问不同的计算机。我通过 winrm 连接然后打开嵌套的 Powershell 会话解决了这个问题。它本质上是刷新允许用户连接到活动目录服务器的令牌。

    请参阅以下内容了解更多信息

    确保为 dnscmd 安装远程服务器管理工​​具 (RSAT)。

    $password = '{pass}' | ConvertTo-SecureString -AsPlainText -Force
    $username = '{user}'
    $cred = New-Object System.Management.Automation.PSCredential -ArgumentList $username,$password
    Invoke-Command -ComputerName localhost -Credential $cred -ConfigurationName svc_dns_middleMan -ScriptBlock {
      '{dnscmd_commands}'
    }
    

    【讨论】:

      猜你喜欢
      • 2014-03-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-08-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多