Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

DHCP scope option reporting

Posted on 2010-08-12
6
Medium Priority
?
505 Views
Last Modified: 2012-05-10
Dear Experts,

Is there any code available, which would allow me to pull the value of a specific DHCP scope option, rather than listing them all, as "netsh dhcp server scope <IP> show optionvalue" does?

Thank you,

Sergey
0
Comment
Question by:SergeyGankin
  • 3
  • 3
6 Comments
 
LVL 43

Accepted Solution

by:
Steve Knight earned 1500 total points
ID: 33427178
Not with the the NETSH command afaik.

You can soon run that through a FIND or FINDSTR command, e.g.

netsh dhcp server scope <IP> show optionvalue | find "optionvalue 3 "

Should bring back the default gateway line (from memory.. I thibk that was 3!)

You could use a FOR command then if necesssary to split of the value from this line:

@echo off
for /f "tokens=3,5,8,10* delims= " %%a in ('type irn70136.txt ^| find "optionvalue 3 "') do (
   echo Server = %%a
   echo Scope = %%b
   echo Option %%c = %%d
)

Steve
0
 

Author Comment

by:SergeyGankin
ID: 33693654
did not quite narrow it down to the right text, but thank you for the suggestion, it was helpful. perhaps i just need to play with it a while.
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 33697152
Please let me know what you have as a script now and what output you are/aren't getting and will see what can be done.  Give me the output of

netsh dhcp server scope x.x.x.x show optionvalue

with any details amended if you wish and what you want out of it - could be you get subtly different output to the script above which is part of one for pullng the details out of a Server 2003 network.
0
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 

Author Comment

by:SergeyGankin
ID: 33825917
Hello dragon-it,

I was not able to get separate output for each individual DHCP cope option. However, using the following type of code allows for manageable output parsing:

        Set objWshScriptExec = objShell.Exec(strQuery)
        Set objStdOut = objWshScriptExec.StdOut

        Do Until objStdOut.AtEndOfStream

              strLine = objStdOut.ReadLine
             
        Loop

Thank you for your help.

Best Regards,

Sergey
0
 

Author Closing Comment

by:SergeyGankin
ID: 33825932
Did not completely resolve my issue, but was quite helpful at pointing me in the right direction.
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 33826224
Fair enough.  Would gladly of assisted more if given the chance (and an example of the failing output). Batch text parsing can be a little tricky but should work as long as the input formats are known.

Steve
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A Cisco router can be configured as a DHCP Server. There are advantages and disadvantages in making your Cisco router work as DHCP Server. Almost all the features for windows DHCP can be configured on Cisco-based DHCP server. Some of the features me…
Learn how to PXE Boot both BIOS & UEFI machines with DHCP Policies and Custom Vendor Classes
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question