DHCP script

I have DHCP on windows 2008 R2
 Please I need a script that gives me as a result the name of scope and the START and END IP address of all scope in DHCP.
THX
DRRAMAsked:
Who is Participating?
 
KenMcFCommented:
We can fix this one
"AN/SITE 9 FSG-JOKSF_IJISD /SI .SG anglais"

by replacing this line

Add a space to the '-'
$l = $l -replace '-',','
$l = $l -replace " -",','


I am not sure about fixing this one, it looks like it is a limitation of netsh

I will try and see if there is another way to get this information, might be able to using WMI.






0
 
Steven CarnahanNetwork ManagerCommented:
Is this what you are looking for?  

http://powershell.com/cs/media/p/1714.aspx
0
 
DRRAMAuthor Commented:
I search for example:

Scope          Start IP Address          End IP Address
site1               18.180.1.1                         18.180.1.222
.....
......  
0
Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

 
DRRAMAuthor Commented:
I wait a response please

I search for example:

Scope          Start IP Address          End IP Address
site1               18.180.1.1                         18.180.1.222
.....
......  
0
 
Steven CarnahanNetwork ManagerCommented:
You could look at Microsoft's powershell module for DHCP. http://gallery.technet.microsoft.com/scriptcenter/05b1d766-25a6-45cd-a0f1-8741ff6c04ec
0
 
Krzysztof PytkoSenior Active Directory EngineerCommented:
I would use netsh utility with dhcp context on DHCP server.
Log on to your 2008R2 DHCP server and in command-line type

netsh dhcp server dump >c:\dhcp.log

and open this file in notepad. Look for "Add Scope" section. There are all scopes and below them you will find IP ranges for them

Regards,
Krzysztof
0
 
DRRAMAuthor Commented:
I wait a response please

I search only the three fields below

Scope          Start IP Address          End IP Address
site1               18.180.1.1                         18.180.1.222
.....
......  
0
 
DRRAMAuthor Commented:
??????
0
 
DRRAMAuthor Commented:
???? I wait a solution
0
 
KenMcFCommented:
Take a look at this blog post. This should give you the information you are looking and uses netsh like iSiek suggested but powershell to parse the output.

http://theadminguy.wordpress.com/2010/04/15/export-dhcp-scopes-and-their-address-pools-to-a-csv-file/

0
 
DRRAMAuthor Commented:
KenMcF
please
What can I change in the script so that I can export the full name of scope
because “Location” take the name of the scope with no spaces and not full name (except 13 characters)
I wait your response
thx
0
 
KenMcFCommented:
Can you post a few examples of your scope names? Do they have spaces and dashes "-" in them?

0
 
DRRAMAuthor Commented:
KenMcF
For example I have in the DHCP
Scope name : AN/SITE 9 FSG-JOKSF_IJISD /SI .SG anglais
After running the script -> the result in the file. csv
15.122.1.0,"255.255.255.224","15.122.1.20","15.122.1.33","AN/SITE9FSG"
comparing :
AN/SITE 9 FSG-JOKSF_IJISD /SI .SG anglais
AN/SITE9FSG

Other example:

Scope name : BU/Tut_Yurto/Qour_Tu_Mexic/Terfgytu
After running the script -> the result in the file. csv
15.122.55.0,"255.255.255.128","15.122.55.62","15.122.55.128","BU/Tut_Yurto/Qour_Tu_"
comparing :
BU/Tut_Yurto/Qour_Tu_Mexic/Terfgytu
BU/Tut_Yurto/Qour_Tu_

I wait your response
thx







0
 
DRRAMAuthor Commented:
KenMcF
please,
The only problem is: it does not give the full name of the scope
you will try if there is another way to get this information?
thx
0
 
DRRAMAuthor Commented:
please,,,??
The only problem is: it does not give the full name of the scope
you will try if there is another way to get this information?
thx
0
 
KenMcFCommented:
this looks to be a limitation of netsh. I have not been able to find another way to get this info. I will keep looking.

0
 
DRRAMAuthor Commented:
Thanks and waiting for your kind reply as soon as possible
0
 
DRRAMAuthor Commented:
?
0
 
DRRAMAuthor Commented:
completly
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.