Using Windows 8 DHCP PowerShell cmdlets with DHCP server running on Windows Server 2008 or Windows Server 2008 R2

Windows Server 2012 and Remote Server Administration Tool (RSAT) for Windows 8 ships with DHCP Server PowerShell cmdlets. You can read more about it in this blog. All these cmdlets can also be used to manage DHCP server running on Windows Server 2008 or Windows Server 2008 R2. There are two ways to run any of the DHCP PowerShell Cmdlets against a remote DHCP server. You can use the DNS name or IP address of the remote computer running the DHCP server in the –ComputerName parameter. Alternatively, you can use –CimSession with input of DNS name/IP address of the remote computer running the DHCP server. With –CimSession, you can also use the a session object, such as the output of a New-CimSession or Get-CimSession cmdlet. When the remote target DHCP server is running on Windows Server 2008 R2 or Windows Server 2008, you will need to use –ComputerName to run the cmdlet.. -CimSession is not supported when the target DHCP server is running on Windows Server 2008 or Windows Server 2008R2. Here is a bit of innards of how DHCP PowerShell works which explains this behaviour. All the DHCP Server PowerShell cmdlets call the DHCP server WMI provider. DHCP Server WMI provider which is installed as part of DHCP RSAT on Windows 8 or Windows Server 2012, in turn uses the DHCP Server Management C API which uses RPC transport. If a DHCP Server PowerShell cmdlet is called with –ComputerName parameter, the PowerShell cmdlet calls the DHCP WMI provider on the local computer which in turn calls the DHCP Server C API on the target computer specified in ComputerName. If the DHCP Server PowerShell cmdlet is called with –CimSession, the PowerShell cmdlet calls the DHCP WMI provider on the computer specified in -CimSession. The WMI provider in this case calls the DHCP Server API on the computer on which WMI provider is running.

Since DHCP Server WMI provider is not supported on Windows Server 2008 and Windows Server 2008 R2, you need to use –ComputerName while using DHCP PowerShell to manage a DHCP server running on Windows Server 2008 or Windows Server 2008 R2.

Below are some examples of the usage of -ComputerName parameter in DHCP PowerShell cmdlets:

This example adds a new IPv4 scope on the remote DHCP server dhcpwin2k8server.contoso.com.

Add-DhcpServerv4Scope -ComputerName dhcpwin2k8server.contoso.com -Name "Lab-1 Network" -StartRange 10.10.10.1 -EndRange 10.10.10.254 -SubnetMask 255.255.255.0

The example below gets the information for all the reserved IPv6 addresses in the specified scope on the remote DHCP server dhcpwin2k8server.contoso.com.

Get-DhcpServerv6Reservation -ComputerName dhcpwin2k8server.contoso.com -Prefix 2001:4898:7020:1020::  

 

Team DHCP