Powershell快速配置DHCP服务(原创)
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
$dhcpscope=read-host -Prompt "请输入dhcp作用域地址"
$scopename=Read-Host -Prompt "请输入dhcp作用域名称"
$scopedescript=Read-Host -Prompt "请输入dhcp作用域的描述"
$Hostname=$env:COMPUTERNAME
$fqdnname=([.dns]::gethostentry($Hostname)).Hostname
$iprangea=Read-Host -Prompt "请输入dhcp分配起始地址"
$iprangeb=Read-Host -Prompt "请输入dhcp分配结束地址"
$ipexcludea=Read-Host -Prompt "请输入dhcp排除起始地址"
$ipexcludeb=Read-Host -Prompt "请输入dhcp排除结束地址"
$ipgateway=Read-Host -Prompt "请输入dhcp分配的网关地址"
$ipdns=Read-Host -Prompt "请输入dhcp分配的dns地址"
ServerManagercmd -i dhcp
Get-Service dhcpserver |Set-Service -StartupType automatic
Start-Service dhcpserver
netshdhcp server add scope $dhcpscope 255.255.255.0 $scopename $scopedescript netshdhcp add server $fqdnname
netshdhcp server scope $dhcpscope add iprange $iprangea $iprangebdhcp netshdhcp server scope $dhcpscope add excluderange $ipexcludea $ipexcludeb netshdhcp server scope $dhcpscope set optionvalue 003 ipaddress $ipgateway netshdhcp server scope $dhcpscope set optionvalue 006 ipaddress $ipdns netshdhcp server scope $dhcpscopeset state 1