Get DHCP Scopes using PowerShell

We need DHCP PowerShell cmdlet to be available in order to manage DHCP. By default, the DHCP module is not loaded in PowerShell. We need to install and the import the DHCP module before we can use it.

Importing DHCP Powershell cmdlet

If you’re going to use PowerShell on the DHCP server, then ensure the Management tools are also installed. Below is the PowerShell command to install DHCP role with management tools

Add-WindowsFeature -Name DHCP –IncludeManagementTools

If you’re going to manage the server remotely, then you can install RSAT tool – features

Add-WindowsFeature RSAT-DHCP

image

Once installed, import the DHCP module before you can use.

Import-Module DhcpServer 

List all the authorized DHCP servers in Active Directory

Get-DhcpServerInDC

image

Get DHCP scope configuration for one scope

Get-DhcpServerv4Scope –ComputerName <DHCPServerName> –ScopeID <ScopeID>

image

Get list of all DHCP scopes on a DHCP server

Get-DhcpServerv4Scope –ComputerName <DHCPServerName>

image

If you need to include more settings like Delay,  Description, Name

Get-DhcpServerv4Scope –ComputerName <DHCPServerName> | FL *
 

Get DHCP Server Option

Get-DhcpServerv4OptionValue -ComputerName <ServerName>
 

Get DHCP Scope option

Returns all scope options for a specified DHCP scope:

Get-DhcpServerv4OptionValue -ComputerName <ServerName> –ScopeID <ScopeID>
 
Example: Get-DhcpServerv4OptionValue -ComputerName MyDHCPSvr01 -Scope 10.10.10.0

Check one particular scope option for a subnet:

Get-DHCPServerv4OptionValue -ComputerName <ServerName> -ScopeID <ScopeID> -OptionID <Option>
 
Example: Get-DhcpServerv4OptionValue –ComputerName MyDHCPSvr01 –ScopeID 10.10.10.0 –OptionID 66