PowerShell to quickly view and bind DHCP users

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.