问题
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