Apologies. wrong script
# Subnet selection
function Show-Menu
{param ( [string]$Title = 'subnet selection' )
Write-Host "================ $Title ================"
Write-Host "1: 192.168.128.0/24"
Write-Host "2: 192.168.129.0/24"
}
do
{Show-Menu
$input = Read-Host "Which subnet will the VM be on"
switch ($input)
{
'1' {2..250|ForEach { if (!((Test-Connection 192.168.128.$_ -count 1 -Quiet) -and (resolve-dnsname -ea 0 192.168.128.$_ ))) {write-Output "IP Address Available 192.168.128.$_ and no DNS entries"}}}
'2' {2..250|ForEach { if (!((Test-Connection 192.168.129.$_ -count 1 -Quiet) -and (resolve-dnsname -ea 0 192.168.129.$_ ))) {write-Output "IP Address Available 192.168.129.$_ and no DNS entries"}}}
}
} until ($input)