【问题标题】:WMIC command for dhcp config win server 2003dhcp config win server 2003 的 WMIC 命令
【发布时间】:2017-03-09 19:15:06
【问题描述】:

我想使用 wmic 在 windows server 2003 上远程配置一些服务,如 dhcp 和 dns。

为此,我在 Windows Server 2003 上使用 java 并连接到 wmic,但我不知道如何在 Windows Server 2003 中通过 wmic 配置 dhcp。

为此目的的命令是什么?

提前致谢

【问题讨论】:

    标签: wmi dhcp wmic


    【解决方案1】:

    不确定 Java,但您可以使用 WMIC 执行 powershell 命令。如果您有 Windows Server 2003 SP2,您应该能够安装 PowerShell 2。

    你需要的命令是:Get-WMIObject Win32_NetworkAdapterConfiguration

    $NICs = Get-WMIObject Win32_NetworkAdapterConfiguration -computername . | 
    where{$_.IPEnabled -eq $true -and $_.DHCPEnabled -eq $true} 
    Foreach($NIC in $NICs) { 
        $ip = ($NIC.IPAddress[0]) 
        $gateway = $NIC.DefaultIPGateway 
        $subnet = $NIC.IPSubnet[0] 
        $dns = $NIC.DNSServerSearchOrder 
        $NIC.EnableStatic($ip, $subnet) 
        $NIC.SetGateways($gateway) 
        $NIC.SetDNSServerSearchOrder($dns) 
        $NIC.SetDynamicDNSRegistration(“FALSE”) 
    }
    

    这是该类的 M$ 参考: https://msdn.microsoft.com/en-us/library/aa394217(v=vs.85).aspx

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-13
      • 1970-01-01
      • 1970-01-01
      • 2013-06-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多