Solved

Set Static IP Address via Powershell

Posted on 2014-12-16
2
419 Views
Last Modified: 2014-12-16
Hi,

I am trying to get a script together that will configure a static IP address, DNS, and WINS server settings. The instructions here are great, except the DNS part doesn't work.

http://blogs.technet.com/b/heyscriptingguy/archive/2012/02/28/use-powershell-to-configure-static-ip-and-dns-settings.aspx

Here are the commands in the script:

$wmi = Get-WmiObject win32_networkadapterconfiguration -filter "ipenabled = 'true'"

$wmi.EnableStatic("192.168.1.2", "255.255.255.0")

$wmi.SetGateways("192.168.1.1", 1)

$wmi.SetDNSServerSearchOrder("208.67.220.220", "208.67.222.222", "8.8.8.8")

$wmi.SetWINSServer("192,168,1,1")

Each time I run the script it fails on the DNS portion. I am doing this on Windows Server 2012. The specific error message is: Cannot find an overload for "SetDNSServerSearchOrder" and the argument count: "3".

Any ideas? Thanks
0
Comment
Question by:Jason Watkins
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 19

Accepted Solution

by:
Raheman M. Abdul earned 500 total points
ID: 40502566
make it as array:
 
$wmi.SetDNSServerSearchOrder(@("208.67.220.220", "208.67.222.222", "8.8.8.8"))

Open in new window


or save the DNS settings into a variable which makes it an array variable like this:
$dnsSearchOrder = "208.67.220.220", "208.67.222.222", "8.8.8.8"
$wmi.SetDNSServerSearchOrder($dnsSearchOrder )

Open in new window

0
 
LVL 27

Author Comment

by:Jason Watkins
ID: 40502644
Option 1 worked great! (after I ran the script as an admin)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A brief introduction to what I consider to be the best editor for PowerShell.
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
In this Micro Tutorial viewers will learn how to restore their server from Bare Metal Backup image created with Windows Server Backup feature. As an example Windows 2012R2 is used.
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question