Solved

Powershell WINS\DNS settings

Posted on 2011-03-16
4
1,547 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

"Migrate" an SMTP relay receive connector to a new server using info from an old server.
Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

743 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

10 Experts available now in Live!

Get 1:1 Help Now