J.C. 的个人资料J.C.'s space日志网络 工具 帮助

日志


1月12日

Collect DHCP information from the command prompt

 I needed to document DHCP information for a client across their large Enterprise consisting of more than 15 DHCP servers and each with several scopes. I dreaded documenting by hand, so I turned to my usual trick of collecting information by command line.
 

First I found just the article I needed about how to get DHCP information at the command line from the Technet Article "To use DHCP commands interactively at the command prompt

My first task was identifying all of the DHCP servers in the organization. Now that could have been easily accomplished from the MMC snap-in, but this is about the Command line. So I used netsh DHCP to accomplish that as well. 

  1. Open Command Prompt.
  2. Type netsh.
  3. At the netsh> command prompt, type dhcp.
  4. At the netsh dhcp> command prompt, type show server. This will give you a list of servers within the current Active Directory domain. 

Now depending on what information you need to retrieve you can dive down into each server and then further into each scope to retrieve information. I needed to identify the scopes on each server, where their databases were located, and some general idea of the usage of each scope. And I needed to record this to a text file. So I decided to go into each server and get targeted information from each one.

So I dug up the following commands:
    server \\Server01     -- Switches which server information is retrieved from. Or, type: server\\IPAddress
    which takes us to the netsh dhcp server> prompt, then I retrieved the information that I wanted using the following commands.
show scope        -- Shows basic scope information
show mibinfo        -- show scope use information
show dbproperties    -- shows Database information
There are several other commands available, use /help to search for the one you need and you can reference this for usage: http://technet.microsoft.com/en-us/library/cc787375.aspx.
You might also look at the dump command. This actually gives you information about each scope and their options when used at the server level. Or you can dig down into each scope using the command: scope ipaddress and use show commands from there.
 
Also the show optiondef command will give you the definitions of each scope option. Option 51 is lease time as measured in seconds (that being the most common one you'll need.)
 

And I discovered that I could run several commands one after the other in a batch file, or in my case by modifying a text file and pasting into the command line.

Netsh
dhcp
server \\Server01
show scope
show mibinfo
show dbproperties
 
server \\Serverdc01
show scope
show mibinfo
show dbproperties
 
server \\Serverdc02
show scope
show mibinfo
show dbproperties
 
server \\Serverrdp01
show scope
show mibinfo
show dbproperties
 

Unfortunately, piping the command out to a text file (>c:\output.txt) didn't work and I didn't have Powershell on the network (Start-Transcript…..). So I ended up listing two or three servers at a time, while using the select all, cut, and paste commands in the CMD.exe window to paste the text into a notepad file.

All in all, a way quicker and cooler way of collecting DHCP information across the organization, than using the GUI.

评论

请稍候...
很抱歉,您输入的评论太长。请缩短您的评论。
您没有输入任何内容,请重试。
很抱歉,我们当前无法添加您的评论。请稍后重试。
若要添加评论,需要您的家长授予您相应权限。请求权限
您的家长禁用了评论功能。
很抱歉,我们当前无法删除您的评论。请稍后重试。
您已超过了一天之内允许提供的评论数上限。请在 24 小时后重试。
因为我们的系统表明您可能在向其他用户提供垃圾评论,您的帐户已禁用了评论功能。如果您认为我们错误地禁用了您的帐户,请联系 Windows Live 支持部门
完成下面的安全检查,您提供评论的过程才能完成。
您在安全检查中键入的字符必须与图片或音频中的字符一致。

若要添加评论,请使用您的 Windows Live ID 登录(如果您使用过 Hotmail、Messenger 或 Xbox LIVE,您就拥有 Windows Live ID)。登录


还没有 Windows Live ID 吗?请注册

引用通告

此日志的引用通告 URL 是:
http://jcwarnerii.spaces.live.com/blog/cns!DAFBEF02F4CD141!160.trak
引用此项的网络日志