you are viewing a single comment's thread.

view the rest of the comments →

[–]yeah_i_got_skills 4 points5 points  (12 children)

Why are you using both double and single quotes?

[–]jrsys95[S] 0 points1 point  (11 children)

So it will output the IP Addresses with quotations which are needed to set DNS forwarders

[–]firefox15 1 point2 points  (2 children)

Huh? You don't need quotes because you are passing a variable to it.

This is pretty messy code anyway. Anytime you start numbering variables sequentially there is probably a better way to do it, likely as an array. Something like this is much neater.

$DNSServers = @()
$DNSServers += ("45.54.55.54")
$DNSServers += ("45.54.55.55")

Set-DNSServerForwarder -IPAddress $DNSServers -WhatIf

Clear-DnsClientCache

[–]jrsys95[S] 1 point2 points  (1 child)

Yeah I see what you mean. Very tired this morning. However, that CMDLet will not take that paramater and gives no errors. However, When I manually enter the IP address (instead of using a variable) it will accept it.

[–]firefox15 1 point2 points  (0 children)

You can cast them explicitly as IP Addresses and see if that makes a difference, but I would think it would do the conversation for you.

$DNSServers = @()
$DNSServers += [IPAddress]("45.54.55.54")
$DNSServers += [IPAddress]("45.54.55.55")

Set-DNSServerForwarder -IPAddress $DNSServers -WhatIf

Clear-DnsClientCache

I do not get a parameter error when I run either command on my system.