LucD,
Thank you for your help. I had a make little change as below to get the only the free IP. Please check, if this is correct ?
As I had to delete this line,
"$computer - available"
$ipRange = 10,254
$ip = $ipRange[0]
do{
$computer = "192.168.1.$ip"
$ip++
}
until(
$ip -gt $ipRange[1] -or -not (Test-Connection $computer -Count 1 -Quiet)
)
if($ip -lt $iprange[1]){
$found = $true
}
else{
"No free IP found"
$found = $false
}
# Check if an IP is available
if($found){
# Use the value in $computer
$computer
}
else{
Write-Error "No free IP found"
}