Hello!
I want to be able to type in a number in the prompt and see which of my scopes has that amount of free IP addresses. I have come this far...
#----------------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
But it dosent seems to work as intended. Seems like the scipt has trouble of counting the free IPs?
Thanks in advance.