PowerShell Genie

DhcpServer module: setup and commands

Module 2 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn

Inspect DHCP scopes, leases, reservations and options with Get-DhcpServerv4Scope before changing address pools or client configuration.

Getting it

Present on a DHCP server. On an admin workstation, install the RSAT DHCP server tools, or use Install-WindowsFeature RSAT-DHCP on Windows Server.

Examples

Show reference output
1 Get -DhcpServerv4Scope -ComputerName DHCP01
Show reference output
1 ScopeId SubnetMask Name State
2 ------- ---------- ---- -----
3 10.20.30.0 255.255.255.0 Corp LAN Active
Show reference output
1 Get -DhcpServerv4Lease -ComputerName DHCP01 -ScopeId 10.0 . 0.0
Show reference output
1 IPAddress ScopeId ClientId HostName AddressState
2 --------- ------- -------- -------- ------------
3 10.20.30.41 10.20.30.0 00-15-5D-21-34-56 WS01 Active

What it is for

Use it to report scope utilization before an address range runs dry, and to reconcile reservations against a source of truth. It also covers failover relationship checks where two servers share responsibility for a scope.

Typical tasks

  • Report scope utilization and free addresses
  • List active leases within a scope
  • Reconcile reservations against an inventory
  • Check server and scope level options
  • Verify failover relationship state
  • Export scope configuration before a migration

Check the installed version

1PS> Get-Module -ListAvailable DhcpServer | Select-Object Name, Version, Path
2PS> Get-Command -Module DhcpServer

Compare the module path and version with the session used by your scheduled task or automation account. Use it to report scope utilization before an address range runs dry, and to reconcile reservations against a source of truth. It also covers failover relationship checks where two servers share responsibility for a scope.

Primary documentation

PowerShell objects and pipelines documentation

Continue
Genie guideDhcpServer module: setup and commands

Inspect DHCP scopes, leases, reservations and options with Get-DhcpServerv4Scope before changing address pools or client configuration.