How to Manage DHCP using PowerShell
Published Aug 01 2019 03:55 AM 53.6K Views

Most organizations are already going to have DHCP deployed on their servers. If you have a new server on which you want to deploy DHCP, just run the PowerShell command:


Install-WindowsFeature DHCP -IncludeManagementTools

Once you’ve installed a DHCP server on a computer running Windows Server, you need to authorize that server in Active Directory. If you don’t do this, then the DHCP server won’t be able to lease addresses to clients. You’ll need to run the command with an account that has Enterprise Admin privileges in the forest, or is a Domain Admin account in the forest root domain.


You can do this by running the PowerShell command (where you substitute in the appropriate FQDN and IP address of the DHCP server that you want to authorize). Note that you don’t need to run this on the DHCP server, you can have someone else with the appropriate privileges run it on a DC.


Add-DhcpServerInDC -DNSName dhcp-srv.contoso.internal -IPAddress

You can view a list of DHCP server that are authorized in AD by running the following command:




Now that the DHCP server is authorized, you’ll need to add a scope. You can do this with the Add-DhcpServerV4Scope cmdlet. For example, to create a scope named Subnet-Alpha that includes the range through with a /24 subnet mask, run the command:


Add-DhcpServerV4Scope -name “Subnet-Alpha” -StartRange -Endrange -SubnetMask -State Active

You can check which scopes are present on a server using the Get-DHCPServerV4Scope cmdlet.


You’ll need to add both a default gateway and a DNS server address to that scope, which you can do with the Set-DhcpServerv4OptionValue cmdlet. For example, to set the DNS server to and the default gateway to for the Subnet-Alpha scope, which has the scope ID (or the first address in the range for the scope) run the command:

Set-DhcpServerV4OptionValue -ComputerName dhcp-srv.contoso.internal -ScopeID -DNSServer -Router

You can then check that the options have been set correctly using the Get-DhcpServerV4OptionValue cmdlet with the ScopeID parameter.



You can view DHCP leases from a specific scope using the Get-DhcpServerv4Lease cmdlet with the ScopeID parameter.



You can use the Add-DhcpServerv4Reservation cmdlet to convert a lease to a reservation. To do this, you need the MAC address, which is represented by the client ID in the output of Get-DHCPServerV4Lease cmdlet. For example, to create a reservation for the computer with the MAC address 00-16-5d-56-9e-04 for the IP address in the scope ID, run the command:

Add-DhcpServerv4Reservation -ScopeID -IPaddress -ClientID “00-15-5d-56-9e-04” -Description “Reservation for MEL-SVR2”

You can validate which reservations are present within a scope using the Get-DhcpServerV4Reservation cmdlet.


If you wish to locate several free IP addresses within a scope that are not being leased, you can use the Get-DhcpServerv4FreeIPAddress cmdlet with the NumAddress parameters. For example, to locate five IP addresses that aren’t being used in the scope, run the command:

Get-DhcpServerv4FreeIPAddress -ScopeID -NumAddress 5


You can learn more about the PowerShell cmdlets that you use to manage DHCP in the following article.

Version history
Last update:
‎Aug 01 2019 03:55 AM
Updated by: