我试着写了一个脚本,会发现(并在以后添加预订)的DHCP设备。我遇到的问题有一个范围,在这个范围内,我们手动划分了不同的IP范围,应该添加某些类型的设备。的Windows,DHCP服务器保留 - 寻找免费的IP地址
E.g.范围10.92.0.0/24和我们指定范围为
10.92.0.10-20的iPhone等 10.92.0.10.50 Android手机等
我已经得到的地步脚本通过我提供给它的IP范围,以及GET GET保留或显示错误。我一直在想,第一个错误可以被视为免费的IP。
任何想法的人? :)
# Get DHCP Scope
$Start = 100
$End = 140
$DHCPServer = "dhcpserver.company.com"
# Find Free IP address
#It can use to get DHCP reservation by IP and find the one which returns error - which can be used as the free one - loop done
#Now how to tell it to stop when the error occures?
While ($Start -le $End) {
$IP = "10.92.0.$Start"
Write-Host "Reservation for: $IP" -ForegroundColor Cyan
Get-DhcpServerv4Reservation -ComputerName $DHCPServer -IPAddress $IP
$Start++
}
詹姆斯它的工作,谢谢! –
没有为获得免费的DHCP服务器租用一个专用的cmdlet:'GET-DhcpServerv4FreeIPAddress'。 – Adamar