Solved

Set Static IP Address via Powershell

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

In this previous article (https://oddytee.wordpress.com/2016/05/05/provision-new-office-365-user-and-mailbox-from-exchange-hybrid-via-powershell/), we made basic license assignments to users in O365. When I say basic, the method is the simplest way …
This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
In this Micro Tutorial viewers will learn how to use Windows Server Backup to create full image of their system. Tutorial shows how to install Windows Server Backup Feature on Windows 2012R2 and how to configure scheduled Bare Metal Recovery backup.…
This tutorial will walk an individual through the process of installing of Data Protection Manager on a server running Windows Server 2012 R2, including the prerequisites. Microsoft .Net 3.5 is required. To install this feature, go to Server Manager…

821 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