Avatar of Jason Watkins
Jason Watkins
Flag for United States of America asked on

Set Static IP Address via Powershell

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
Windows Server 2012PowershellWindows Batch

Avatar of undefined
Last Comment
Jason Watkins

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Raheman M. Abdul

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Jason Watkins

ASKER
Option 1 worked great! (after I ran the script as an admin)
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck