title: Set DNS with PowerShell
body: <p><strong>What I am trying to accomplish:</strong> I am trying to set the DNS address on my machine using powershell.</p>
  
  <p><strong>Here is my code:</strong></p>
  
  <pre><code>$dnsserver = (,"192.168.0.5")
  Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter IPEnabled=TRUE | Invoke-WmiMethod -Name SetDNSServerSearchOrder -ArgumentList (,$dnsserver)
  </code></pre>
  
  <p><strong>I am using this as reference:</strong></p>
  
  <p><a href="http://itknowledgeexchange.techtarget.com/powershell/using-invoke-wmimethod-to-set-the-dns-servers/" rel="noreferrer">Using Invoke-WmiMethod to set the DNS servers</a></p>
  
  <p><strong>The problem:</strong> 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. </p>
  
  <p>I am only wanting to add 1 DNS address. </p>
  
  <p>Do I perhaps need to run as a different user or do something else special in order for this to work?</p>