So I'm trying to write a script that sets the DNS forwarders to 2 preset IP's but if the user wants to choose other IP's he just needs to give them in the prompt.
Write-Host " "
Write-Host "DNS Forwarders are set on -192.168.20.3 & 168.192.24.3- want to choose these?"
$Antw = Read-Host -Prompt 'y/n'
If ($Antw.ToLower() = "n")
{
$ip1 = Read-Host -Prompt 'DNS Forwarder 1: '
$ip2 = Read-Host -Prompt 'DNS Forwarder 2: '
C:\Windows\System32\dnscmd.exe $hostname /resetforwarders $ip1, $ip2
}
Elseif ($Antw.ToLower() = "y")
{
C:\Windows\System32\dnscmd.exe $hostname /resetforwarders 192.168.20.3, 168.192.24.3
}
#Write-Host $Antw
My If/ElseIf doesn't seem to be working however, If I press 'y', it still asks for the 2 ip's?? what's wrong with my code?
Thanks