Partager via


Script to display ALL the reserved addresses configured on the DHCP server.

The Microsoft DHCP server provides show command to display reserved addresses configured at a particular scope level. But diplaying ALL the reserved addresses configured in ALL the scopes in the server is not possible with a single command.

 You can make use of the below script (Batch File) to display the reservations for all the scopes configured in the server. An intermidiate file named "display.nsh" will be created in the current folder but it gets deleted once the script execution completes.

 

Note:   The below script contents are for running as a batch file. If you are running directly on the console (ie not as a batch file), please replace all occurrences of %%i in the script with %i.

 

 

Script for DHCPV4 (Display_DHCPV4_Reservations.bat)

*********************************************************************************************************

@echo off

del display.nsh > nul 2> nul

for /F "skip=4 tokens=1 delims== " %%i in ('netsh dhcp server show scope') do if NOT %%i == Total if NOT %%i == Command echo dhcp server scope %%i show reservedip >> display.nsh

netsh -f display.nsh

del display.nsh > nul 2> nul

*********************************************************************************************************

 

 

Script for DHCPV6 (Display_DHCPV6_Reservations.bat)

 

*********************************************************************************************************

@echo off

del display.nsh > nul 2> nul

for /F "skip=4 tokens=1 delims== " %%i in ('netsh dhcp server v6 show scope') do if NOT %%i == Total if NOT %%i == Command echo dhcp server v6 scope %%i show reservedip >> display.nsh

netsh -f display.nsh

del display.nsh > nul 2> nul

*********************************************************************************************************

 

Thanks,

Gnana Pandian.C

Team DHCP.

Comments

  • Anonymous
    January 01, 2003
    It appears the Networking team is looking for feedback on how to improve future releases of the Microsoft DHCP server role in Windows Server. For me, the first thing that comes to mind is: Add WMI support This has always been one of the "Duh" points in