Deploy DHCP Using Windows PowerShell | Microsoft Docs TCP/IP properties with the correct DNS server IP address. You must also replace interface names and IP addresses in this example with the values that you want to use to configure your computer. <span>New-NetIPAddress -IPAddress 10.0.0.3 -InterfaceAlias "Ethernet" -DefaultGateway 10.0.0.1 -AddressFamily IPv4 -PrefixLength 24 Set-DnsClientServerAddress -InterfaceAlias "Ethernet" -ServerAddresses 10.0.0.2 For more information about these commands, see the following topics. New-NetIPAddress Set-DnsClientServer
Deploy DHCP Using Windows PowerShell | Microsoft Docs le with the values that you want to use to configure your computer. New-NetIPAddress -IPAddress 10.0.0.3 -InterfaceAlias "Ethernet" -DefaultGateway 10.0.0.1 -AddressFamily IPv4 -PrefixLength 24 <span>Set-DnsClientServerAddress -InterfaceAlias "Ethernet" -ServerAddresses 10.0.0.2 For more information about these commands, see the following topics. New-NetIPAddress Set-DnsClientServerAddress Rename the computer You can use the following commands to rename and the
Deploy DHCP Using Windows PowerShell | Microsoft Docs ation about these commands, see the following topics. New-NetIPAddress Set-DnsClientServerAddress Rename the computer You can use the following commands to rename and then restart the computer. <span>Rename-Computer -Name DHCP1 Restart-Computer For more information about these commands, see the following topics. Rename-Computer Restart-Computer Join the computer to the domain (Optional) If you are installing y
Deploy DHCP Using Windows PowerShell | Microsoft Docs see the following topics. New-NetIPAddress Set-DnsClientServerAddress Rename the computer You can use the following commands to rename and then restart the computer. Rename-Computer -Name DHCP1 <span>Restart-Computer For more information about these commands, see the following topics. Rename-Computer Restart-Computer Join the computer to the domain (Optional) If you are installing your DHCP server i
Deploy DHCP Using Windows PowerShell | Microsoft Docs pen Windows PowerShell with Administrator privileges, and then run the following command after replacing the domain NetBios name CORP with a value that is appropriate for your environment. Copy <span>Add-Computer CORP When prompted, type the credentials for a domain user account that has permission to join a computer to the domain. Copy Restart-Computer For more information about the Add-Computer com
Deploy DHCP Using Windows PowerShell | Microsoft Docs e the following topic. Add-Computer Install DHCP After the computer restarts, open Windows PowerShell with Administrator privileges, and then install DHCP by running the following command. Copy <span>Install-WindowsFeature DHCP -IncludeManagementTools For more information about this command, see the following topic. Install-WindowsFeature Create DHCP security groups To create security groups, you must run a Network Shell (netsh) comm
Authorize the DHCP server in Active Directory (Optional)
If you are installing DHCP in a domain environment, you must perform the following steps to authorize the DHCP server to operate in the domain.
Note
Unauthorized DHCP servers that are installed in Active Directory domains cannot function properly, and do not lease IP addresses to DHCP clients. The automatic disabling of unauthorized DHCP servers is a security feature that prevents unauthorized DHCP servers from assigning incorrect IP addresses to clients on your network.
You can use the following command to add the DHCP server to the list of authorized DHCP servers in Active Directory.
Note
If you do not have a domain environment, do not run this command.
Notify Server Manager that post-install DHCP configuration is complete (Optional)
After you have completed post-installation tasks, such as creating security groups and authorizing the DHCP server in Active Directory, Server Manager might still display an alert in the user interface stating that post-installation steps must be completed by using the DHCP Post Installation Configuration wizard.
You can prevent this now-unnecessary and inaccurate message from appearing in Server Manager by configuring the following registry key using this Windows PowerShell command.
Deploy DHCP Using Windows PowerShell | Microsoft Docs become active. When you run the following netsh command on the DHCP server, the DHCP Administrators and DHCP Users security groups are created in Local Users and Groups on the DHCP server. Copy <span>netsh dhcp add securitygroups The following command restarts the DHCP service on the local computer. Copy Restart-service dhcpserver For more information about these commands, see the following topics. Network Shell
Deploy DHCP Using Windows PowerShell | Microsoft Docs CP Users security groups are created in Local Users and Groups on the DHCP server. Copy netsh dhcp add securitygroups The following command restarts the DHCP service on the local computer. Copy <span>Restart-service dhcpserver For more information about these commands, see the following topics. Network Shell (Netsh) Restart-Service Authorize the DHCP server in Active Directory (Optional) If you are installing
Deploy DHCP Using Windows PowerShell | Microsoft Docs work. You can use the following command to add the DHCP server to the list of authorized DHCP servers in Active Directory. Note If you do not have a domain environment, do not run this command. <span>Add-DhcpServerInDC -DnsName DHCP1.corp.contoso.com -IPAddress 10.0.0.3 To verify that the DHCP server is authorized in Active Directory, you can use the following command. Copy Get-DhcpServerInDC Following are example results that are displayed in Windows
How do you verify that the DHCP server is authorized in Active Directory ?
Answer
Get-DhcpServerInDC
status
not learned
measured difficulty
37% [default]
last interval [days]
repetition number in this series
0
memorised on
scheduled repetition
scheduled repetition interval
last repetition or drill
Deploy DHCP Using Windows PowerShell | Microsoft Docs un this command. Add-DhcpServerInDC -DnsName DHCP1.corp.contoso.com -IPAddress 10.0.0.3 To verify that the DHCP server is authorized in Active Directory, you can use the following command. Copy <span>Get-DhcpServerInDC Following are example results that are displayed in Windows PowerShell. Copy IPAddress DnsName --------- ------- 10.0.0.3 DHCP1.corp.contoso.com For more information about these command
This example command also configures the DHCP server to delete DNS resource records for clients when the client least expires.
status
not learned
measured difficulty
37% [default]
last interval [days]
repetition number in this series
0
memorised on
scheduled repetition
scheduled repetition interval
last repetition or drill
Deploy DHCP Using Windows PowerShell | Microsoft Docs computers, you can run the following command to configure this setting. This is a server level setting, not a scope level setting, so it will affect all scopes that you configure on the server. <span>This example command also configures the DHCP server to delete DNS resource records for clients when the client least expires. Copy Set-DhcpServerv4DnsSetting -ComputerName "DHCP1.corp.contoso.com" -DynamicUpdates "Always" -DeleteDnsRRonLeaseExpiry $True You can use the following command to configure the creden
How do you update resource records on your DNS Server ?
Answer
The command prompts you for user name and password, so ensure that you provide credentials for an account that has permission to update resource records on your DNS server:
Deploy DHCP Using Windows PowerShell | Microsoft Docs ntial variable. The command prompts you for user name and password, so ensure that you provide credentials for an account that has permission to update resource records on your DNS server. Copy <span>$Credential = Get-Credential Set-DhcpServerDnsCredential -Credential $Credential -ComputerName "DHCP1.corp.contoso.com" For more information about these commands, see the following topics. Set-DhcpServerv4DnsSetting Set-DhcpServerDnsCredential Configure the Corpnet Scope After DHCP installation is comple
Deploy DHCP Using Windows PowerShell | Microsoft Docs g commands to configure and activate the Corpnet scope, create an exclusion range for the scope, and configure the DHCP options default gateway, DNS server IP address, and DNS domain name. Copy <span>Add-DhcpServerv4Scope -name "Corpnet" -StartRange 10.0.0.1 -EndRange 10.0.0.254 -SubnetMask 255.255.255.0 -State Active` Add-DhcpServerv4ExclusionRange -ScopeID 10.0.0.0 -StartRange 10.0.0.1 -EndRange 10.0.0.15` Set-DhcpServerv4OptionValue -OptionID 3 -Value 10.0.0.1 -ScopeID 10.0.0.0 -ComputerName DHCP1.
Deploy DHCP Using Windows PowerShell | Microsoft Docs ope -name "Corpnet" -StartRange 10.0.0.1 -EndRange 10.0.0.254 -SubnetMask 255.255.255.0 -State Active` Add-DhcpServerv4ExclusionRange -ScopeID 10.0.0.0 -StartRange 10.0.0.1 -EndRange 10.0.0.15` <span>Set-DhcpServerv4OptionValue -OptionID 3 -Value 10.0.0.1 -ScopeID 10.0.0.0 -ComputerName DHCP1.corp.contoso.com` Set-DhcpServerv4OptionValue -DnsDomain corp.contoso.com -DnsServer 10.0.0.2 For more information about these commands, see the following topics. Add-DhcpServerv4Scope Add-DhcpServerv4Ex
Deploy DHCP Using Windows PowerShell | Microsoft Docs erverv4ExclusionRange -ScopeID 10.0.0.0 -StartRange 10.0.0.1 -EndRange 10.0.0.15` Set-DhcpServerv4OptionValue -OptionID 3 -Value 10.0.0.1 -ScopeID 10.0.0.0 -ComputerName DHCP1.corp.contoso.com` <span>Set-DhcpServerv4OptionValue -DnsDomain corp.contoso.com -DnsServer 10.0.0.2 For more information about these commands, see the following topics. Add-DhcpServerv4Scope Add-DhcpServerv4ExclusionRange Set-DhcpServerv4OptionValue Configure the Corpnet2 Scope (Optio