Here I want to run nslookup with specified types of DNS records in PowerShell.
I tried it by define the types of DNS records and run nslookup with Foreach.
$types = @("soa", "a")
Foreach ($type in $types){
nslookup -type=$type google.com
}
But this doesn’t seem to work because $type is not recognized as a parameter.
Does anyone know how to solve this problem?
>Solution :
Quote the whole argument, including the parameter name, with double-quotes – this will prevent PowerShell from interpreting -type as a managed parameter:
nslookup "-type=$type" google.com