捕获“netsh dhcp服务器显示范围”

时间:2013-11-20 20:11:18

标签: powershell dhcp

我需要捕获

的输出
netsh dhcp server show scope

显示如下:

==============================================================================
 Scope Address  - Subnet Mask    - State        - Scope Name          -  Comment
==============================================================================

 10.5.116.0     - 255.255.255.0  -Active        -LAN 1               -VLAN 1
 10.17.134.0    - 255.255.255.128-Active        -LAN 2               -VLAN 2
在powershell变量中的

(如果可能的话,是一个数组)。所以我有line1与Scope,Subnet,...(例如$ Line1 ['Scope'])

但我无法管理。有人可以帮助我在这里找到一个起点吗?有用的将是我如何捕捉整条线。

3 个答案:

答案 0 :(得分:1)

Server 2012& Windows 8:Powershell - DHCP Scopes in Powershell

中描述的DHCP服务器管理模块

Powershell V3(可能是V2):获取Powershell Module for DHCP并使用Get-DHCPScope

答案 1 :(得分:0)

据我所知,netsh是在服务器上使用Powershell管理DHCP的唯一方法,但存在WMI DHCP Server Classes的W2K12除外。

顺便说一下,您不必重新发明轮子就会发现使用netsh的PowerShell Module for DHCP。我不测试它,但看起来很有希望。

答案 2 :(得分:0)

Get-DhcpServerv4Scope | export-csv C:\temp\dhcp.csv