What I am trying to accomplish: I am trying to set the DNS address on my machine using powershell.
Here is my code:
$dnsserver = (,"192.168.0.5")
Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter IPEnabled=TRUE | Invoke-WmiMethod -Name SetDNSServerSearchOrder -ArgumentList (,$dnsserver)
I am using this as reference:
Using Invoke-WmiMethod to set the DNS servers
The problem: When I run the script, nothing changes. If I run the script and restart the machine, nothing happens. I am running the script on my local machine not remotely.
I am only wanting to add 1 DNS address.
Do I perhaps need to run as a different user or do something else special in order for this to work?
managing network interfaces usualy require administrative rights, so you have to run your script in an elevaled powershell console.