Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to pass parameter to type option of nslookup in powershell?

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading