powershell - 如果免费 IP 高于或低于输入数字,我如何询问 DHCP 范围?(电源外壳)
问题描述
我希望能够在提示符中输入一个数字,并查看我的哪个范围有这么多的空闲 IP 地址。我已经走到这一步了……
#----------------CODE---------------------
Write-Host "Enter number off IP-addresses: " -FO blue
$input = Read-Host
$SCOPES = Get-DhcpServerv4Scope
$count = 0
foreach($scope in $SCOPES)
{
$scopeID = $scope.ScopeID
$freeIP = Get-DhcpServerv4FreeIPAddress -ScopeID $scope.ScopeID -NumAddress 1024
foreach ($freeIP in $scope)
{
$count ++
}
if($count -lt $input)
{
Write-Host $scopeID " has less than " $input " free IP addresses."
}
elseif($count -gt $input)
{
Write-Host $scopeID " has more than " $input " free IP addresses."
}
}
#--------------END OF CODE
但它似乎按预期工作。似乎 scipt 在计算免费 IP 时遇到了麻烦?
提前致谢。
解决方案
推荐阅读
- c# - 按 Android 上的后退按钮关闭/隐藏键盘正在清除我的输入字段 Unity
- java - 在 Java 中遍历数组时出现 Nullpointer 异常
- powershell - 从函数返回字节数组时内存消耗高
- python - 如何从表单 django 发送电子邮件
- android - 如何在服务器端使用开发者的公钥验证购买是否正确签名,将使应用程序更安全?
- sql - 子类别查询
- r - 如何正确地将示例添加到写入文件的 R 函数中
- python - StyleFrame 对象的深拷贝
- java - 在 android studios 和 firebase 实时数据库中,有什么功能可以获取某些特定数据的子参数的名称?
- python-3.x - 可视化代码,使用 anaconda 安装请求,但仍然提示“ImportError: No module named requests”