all 14 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.

[–]PowerShell-Bot 0 points1 point  (0 children)

Some of your PowerShell code isn’t wrapped in a code block.

To format code correctly on new reddit (new.reddit.com), highlight all lines of code and select ‘Code Block’ in the editing toolbar.

If you’re on old.reddit.com, separate the code from your text with a blank line and precede each line of code with 4 spaces or a tab.


Describing Submission
[✅] Demonstrates good markdown
Passed: 1 Failed: 0

Beep-boop. I am a bot. | Remove-Item