Author Posts

January 1, 2012 at 12:00 am

by Upinit at 2012-12-03 16:23:56

I'm not well versed with Powershell and need some assistance. I have a small script I would like to use that will set the IP, subnet mask, default gateway, DNS, and WINS on NIC. I googled and found examples and everyhting is working except the WINS part. I am receiving a Return Value of 68 instead of a 0 for just the WINS portion.

Here is my script:

$ip = read-host "Enter the IP address of the server"
$gateway = read-host "Enter the Gateway of the server"
$wmi = get-wmiobject win32_networkadapterconfiguration -filter "ipenabled = 'true'"
$wmi.EnableStatic($ip,"255.255.255.0")
$wmi.SetGateways($gateway,1)
$wmi.SetDNSServerSearchOrder("172.16.2.10")
$wmi.SetWINSServer("172.16.2.10")

Can someone direct me to a potential solution?

Thanks!

by Upinit at 2012-12-03 20:14:44

I found the solution, you have to supply a second WINS address for some reason so I supplied a null entry.

$wmi.SetWINSServer("172.16.2.10","")

by Klaas at 2012-12-04 00:58:26

I think that's because there are 2 properties: WINSPrimaryServer and WINSSecondaryServer that both will be set with the SetWINSServer method. This is different from the DNSServerSearchOrder which is a collection to which you can submit 1,2,or more IPs.

by RichardSiddaway at 2012-12-04 08:52:37

Documentation on the SetWinsServer() method is here http://msdn.microsoft.com/en-us/library ... 24(v=vs.85).aspx