Solved

Powershell WINS\DNS settings

Posted on 2011-03-16
4
1,548 Views
Last Modified: 2012-05-11
I have got this to change DNS\WINS settings

# Unhash DNS sections if required.

function SetDNSWINS {
#Get NICS via WMI
$NICs = Get-WmiObject -Class Win32_NetworkAdapterConfiguration -ComputerName $_ -Filter "IPEnabled=TRUE"

foreach($NIC in $NICs) {
#$DNSServers = "2.2.2.1","2.2.2.2"
#$NIC.SetDNSServerSearchOrder($DNSServers)
#$NIC.SetDynamicDNSRegistration("TRUE")
$NIC.SetWINSServer("1.1.1.111","1.1.1.222")
}
}

function GetFileName {
$computer = "c:\temp\serverlist.txt"
return $computer
}

$f = GetFileName
Get-Content $f | foreach {SetDNSWINS}

This does it on all adapters how can I get it to only change WINS address on adapters that already have a value there?  The reason is because of things like cluster heart beat etc?

Thanks
0
Comment
Question by:korin123
  • 2
  • 2
4 Comments
 
LVL 8

Accepted Solution

by:
jwarnken earned 500 total points
ID: 35149671
Give this a try
# Unhash DNS sections if required.

function SetDNSWINS {
#Get NICS via WMI
$NICs = Get-WmiObject -Class Win32_NetworkAdapterConfiguration -ComputerName $_ -Filter "IPEnabled=TRUE"

foreach($NIC in $NICs) {
#$DNSServers = "2.2.2.1","2.2.2.2"
#$NIC.SetDNSServerSearchOrder($DNSServers)
#$NIC.SetDynamicDNSRegistration("TRUE")
if(!($NIC.WINSPrimaryServer -eq $null)){$NIC.SetWINSServer("1.1.1.111","1.1.1.222")}
}
}

function GetFileName {
$computer = "c:\temp\serverlist.txt"
return $computer
}

$f = GetFileName
Get-Content $f | foreach {SetDNSWINS}

Open in new window

0
 

Author Comment

by:korin123
ID: 35150110
Thanks a lot for the quick reply.

To confirm will this only change adapters with current WINS settings and leave blank one's blank.
i will try tomorrow in the lab


Thanks again
0
 
LVL 8

Expert Comment

by:jwarnken
ID: 35150223
The change will look for a non blank entry in the Primary Wins Server. If it is not blank it will update the wins servers. If it is blank no change is made.
0
 

Author Closing Comment

by:korin123
ID: 35154500
Thanks a lot work a treat :)
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Synchronize a new Active Directory domain with an existing Office 365 tenant
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.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

911 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now