Solved

Set Static IP Address via Powershell

Posted on 2014-12-16
2
428 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

The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
In this Micro Tutorial viewers will learn how they can get their files copied out from their unbootable system without need to use recovery services. As an example non-bootable Windows 2012R2 installation is used which has boot problems.
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…

707 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