Adding WINS ip to server NIC configuration

I'm needing to add a WINS server entry to a bunch of servers(please don't ask why).
I modified a DNS script I used recently and although it runs, it does not actually add the WINS entry.
$computer = get-content .\systems.txt
$NICs = Get-WMIObject Win32_NetworkAdapterConfiguration -computername $computer |where{$_.IPEnabled -eq “TRUE”}
  Foreach($NIC in $NICs) {
#$WINSServers = “1.2.2.2",”1.2.2.3"
$NIC.SETWINSSERVER (“1.2.2.2",”1.2.2.3")
}

Open in new window


I tried it with and without $winsservers, same result, the IP is not added to wins entry on the server.

I actually only need one entry, not 2, but when it failed initially, I added the second entry to rule out that being the issue somehow.
LVL 3
SquigglyMonkeyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

footechCommented:
I see some odd quotes in the above code, so let's make sure those aren't the issue.  There also shouldn't be a space before the parentheses.
$WINSServers = "1.2.2.2"
$NIC.SetWINSServer($WINSServers)

Open in new window

Let's see if it works with that syntax.
SquigglyMonkeyAuthor Commented:
Sadly no, I did that earlier also, when I was writing this post I used the old "fake IP's" which had the odd double quotes.

How can I find all of the set commands that are available like setwinsserver? Maybe I am using the wrong one?
footechCommented:
To see all properties and methods you just pipe the object to Get-Member, but no, there's no other method that applies to WINS settings.

It looks like you have to supply both primary and secondary WINS servers.  If you don't have a secondary, then just an empty string will do.
$WINSServers = "1.2.2.2",""

Open in new window

I just confirmed this to work on a test machine.

When you run the SetWINSServer method, you will get a code back.  If the resultcode is anything other than 0 it is an error.  This page shows what the different errors are - https://docs.microsoft.com/en-us/windows/desktop/cimwin32prov/setwinsserver-method-in-class-win32-networkadapterconfiguration
Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

SquigglyMonkeyAuthor Commented:
I don't get it... Getting error 68
This is the exact script, just the ip is changed.
$computer = get-content .\systems.txt
$NICs = Get-WMIObject Win32_NetworkAdapterConfiguration -computername $computer |where{$_.IPEnabled -eq "TRUE”}
  Foreach($NIC in $NICs) {
$WINSServers = "1.1.1.1",""
$NIC.SETWINSSERVER($winsservers)
}

Open in new window

footechCommented:
Ah, I tested with a slight variation than what I posted.  Should have known better...
Change your lines 4 and 5 like below.
$WINSServers = "1.1.1.1"
$NIC.SETWINSSERVER($winsservers,"")

Open in new window


You could also do something like
$PrimaryWINS = "1.1.1.1"
$SecondaryWINS = "1.1.1.2"
$NIC.SETWINSSERVER($PrimaryWINS,$SecondaryWINS)

Open in new window

It's basically about the difference between a string array vs. two separate strings.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SquigglyMonkeyAuthor Commented:
Thanks Foo, that did it. Moving that ,""  came up with error 0.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
powerhsell

From novice to tech pro — start learning today.