$a=Read-Host "请输入安装的服务名:"

ServerManagercmd -install $a
Set-Service dhcpserver -StartupType automatic
Start-Service -Name dhcpserver
$b=Read-Host "请输入区域的IP网段:"
$c=Read-Host "请输入子网掩码:"
$d=Read-Host "请输入DHCP的作用域名称:"
$e=Read-Host "请输入DHCP作用域的描述:"
netsh $a server add scope $b $c $d $e
$f=Read-Host "请输入起始IP"
$g=Read-Host "请输入结束IP"
netsh $a server scope $b add iprange $f $g $a
$h=Read-Host "请输入排除IP的起始地址:"
$i=Read-Host "请输入排除IP的结束地址:"
netsh $a server scope $b add excluderange $h $i
$j=Read-Host "请输入网关地址:"
$k=Read-Host "请输入DNS地址:"
netsh $a server scope $b set optionvalue 003 ipaddress $j
netsh $a server scope $b set optionvalue 006 ipaddress $k
netsh $a server scope $b set state 1
Write-Host "DHCP配置完成并以激活!"