PowerShell required for DHCP 4.0 R2 system
This script can be easily called by SCO and programmed, and can be made into approval flow, which makes it easy for users to submit application for binding IP.
Get-dhcpserverv4lease-computername dc.contoso.com-ipaddress 192.168.136.25|select IPAddress,hostname,addressstate , leaseexpirytime# the above statement to get 192.168.136.25 this IP in the DHCP server (dc.contoso.com) property Get-dhcpserverv4scope-computername dc.contoso.com | Get-dhcpserverv4lease-computername dc.contoso.com|select ipaddress,hostname,addressstate# Gets the IP addresses in all scopes under the server, and simply sift through the get-dhcpserverv4lease-computername dc.contoso.com-ipaddress 192.168.136.25| Set-dhcpserverv4reservation gets the relevant information of 192.168.136.25 and binds Get-dhcpserverv4lease-computername dc.contoso.com with the corresponding description information- IPAddress 192.168.136.25|select ipaddress,hostname,addressstate,leaseexpirytime# again look at the IP in all scopes
You can add some variables that are easy for administrators to handle, such as
$a = read-host ("Please enter an IP address that needs to be bound on the dc.contoso.com, similar to XXX.XXX.XXX.XXX") get-dhcpserverv4lease-computername Dc.contoso.com-ipaddress $a | Set-dhcpserverv4reservation
Of course, the above script can also be modified to adapt to different IP ranges, that is, to specify a different server name. So this is a bit of a hassle, requiring user input to be scoped, or defining some property values, such as using a switch statement like the following
$zone 1 = read-host ("Please select the area where the employee is located: (1) Beijing, (2) Tengda, (3) Guangzhou, (4) Shanghai, (5) Chengdu, (6) XI ' an:") switch ($zone 1) {1 {$zone 2 = "Beijing"} 2 {$zone 2 = "Tengda"} 3 {$zone 2 = "Guangzhou"} 4 {$zone 2 = "Shanghai"} 5 {$zone 2 = "Chengdu"} 6 {$zone 2 = "Xi ' an"}}
This article is from the "Nine uncle-Microsoft Private Cloud" blog, please make sure to keep this source http://jiushu.blog.51cto.com/972756/1650293
PowerShell to quickly view and bind DHCP users