Thought I’d squeeze in this post before Windows Server 2003 drifts off into the sunset. (Don’t pretend like you don’t have these servers floating around.)
Okay, so, I was recently asked to validate that some DHCP scope work was performed correctly. Validation in this case was to pull all the scope options. It would have been immensely helpful to use PowerShell to do this. However, I made do without it using Netsh.
Retrieving Scope Options for a Single Scope
netsh dhcp server <servername> scope <scopeaddr> show optionvalue
That’s easy. How about for every scope on my server? That’s easy, too, as it turns out.
Retrieving Scope Options for All Scopes
for /f %a in ('netsh dhcp server <servername> show scope ^| find /i "."' ) do @netsh dhcp server <servername> scope %a show optionvalue