Powershell - DHCP Scopes in Powershell

不羁岁月 提交于 2019-12-24 08:56:36

问题


Working on a script to fully automate the deployment of a new 2012 box as a DC - with Windows updates configured, AD installed, Forest Created, DNS zones configured, DHCP scopes activated etc.

I am working on the DHCP part at the moment and have the following:

Add-WindowsFeature  -IncludeManagementTools dhcp
netsh dhcp add securitygroups
Restart-service dhcpserver
Add-DhcpServerInDC  $Env:COMPUTERNAME  $ip

Add-DhcpServerv4Scope -Name "Client LAN" -StartRange $ipRangeStart -EndRange $ipRangeEnd -      SubnetMask $subnet 

This is great, but I want to also configure DNS Servers and Router (Default Gateway), but I can't find much around on how to do this!

Any ideas?


回答1:


Here's how My small test lab is setup:

Install-WindowsFeature DHCP -IncludeManagementTools
Import-Module DHCPServer -Verbose:$False
Add-DhcpServerV4Scope -Name "ReskitNet0" `
                      -StartRange 10.0.0.100 `
                      -EndRange 10.0.0.219 `
                      -SubnetMask 255.255.255.0
Set-DhcpServerV4OptionValue -DnsDomain Reskit.Org `
                            -DnsServer 10.0.0.10                     
Add-DhcpServerInDC -DnsName Dc1.reskit.org



回答2:


Check the set-dhcpserverv4optiondefinition and set-dhcpserverv4optionvalue cmdlets.

http://technet.microsoft.com/en-us/library/jj590710.aspx



来源:https://stackoverflow.com/questions/15177949/powershell-dhcp-scopes-in-powershell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!