You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Invoke-Command执行Add-DhcpServerInDC时遇访问拒绝错误

多网络DHCP自动化配置授权问题

环境信息

  • 机器AutoDHCP配置双IP:
    • 172.16.0.13:归属Adatum域所在网络
    • 172.16.18.21:归属中继代理所在网络
  • 域控制器LON-DC1:IP为172.16.0.10,需在此服务器上完成DHCP服务器授权操作
  • 域:Adatum.com
  • 操作账户:Adatum\Administrator

执行的PowerShell脚本

$DCUser = "Adatum\Administrator"
$DCPass = ConvertTo-SecureString "Pa55w.rd" -AsPlainText -Force
$DCRemoteCredential = New-Object System.Management.Automation.PSCredential ($DCUser, $DCPass)
Set-Item WSMan:\localhost\Client\TrustedHosts "172.16.0.10"
$DC1 = New-PSSession -ComputerName 172.16.0.10 -Credential $DCRemoteCredential
Invoke-Command -Session $DC1 -Scriptblock {Add-DhcpServerInDC -DnsName "AutoDHCP" -IPAddress 172.16.18.21}
Invoke-Command -Session $DC1 -Scriptblock {Add-DhcpServerInDC -DnsName "AutoDHCP" -IPAddress 172.16.0.13}
Remove-PSSession $DC1

预期结果

警告:DHCP服务器autodhcp(IP 172.16.18.21)已在Active Directory中授权。已启动DHCP服务器授权检查。
警告:DHCP服务器autodhcp(IP 172.16.0.13)已在Active Directory中授权。已启动DHCP服务器授权检查。

实际结果

警告:DHCP服务器autodhcp(IP 172.16.18.21)已在Active Directory中授权

无法启动DHCP服务器授权检查。错误:访问被拒绝。(5)。
警告:DHCP服务器autodhcp(IP 172.16.0.13)已在Active Directory中授权。

无法启动DHCP服务器授权检查。错误:访问被拒绝。(5)。

问题说明

直接在LON-DC1本地执行脚本可正常运行,但需要将该操作整合进AutoDHCP机器的大型自动化脚本中(服务器重启后支持手动输入密码),当前所有远程执行尝试均失败,寻求解决方法。

内容的提问来源于stack exchange,提问作者Crazy Boy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.22 04:06:05