Ying Li at myITforum.com

PowerShell & System Center

PowerShell script to update WINS settings for a particular NIC on multiple remote machines

Here is a PowerShell script to udpate WINS settings on a particular NIC on multple remote machines

#You may need to run this under different user context

$cred = get-credential

Function Update-WINS
{

# Here we target a particular NIC of interest
$Nic = Get-WMIObject Win32_NetworkAdapter -comp $strComputer |where{$_.NetConnectionID -eq "Local Area Connection"}

$Config  = Get-WMIObject Win32_NetworkAdapterConfiguration -comp $strComputer |where{$_.MACAddress -eq $Nic.MACAddress}

$pri = $config.winsprimaryserver
$sec = $config.winsSecondaryServer

Write-host "The Current Primary WINS Server on $strComputer is $pri"
Write-host "The Current Secondary WINS Server on $strComputer is $sec"

$config.SetWinsServer("192.168.1.10","192.168.1.11") |out-null
}

foreach ($strComputer in get-content c:\temp\ServerList.txt)
{
Update-WINS
}

Once you done with the change, you could run the following slightly different script to verify the changes

$cred = get-credential

Function Check-WINS
{
$Nic = Get-WMIObject Win32_NetworkAdapter -comp $strComputer |where{$_.NetConnectionID -eq "Local Area Connection"}

$Config   = Get-WMIObject Win32_NetworkAdapterConfiguration -comp $strComputer |where{$_.MACAddress -eq $Nic.MACAddress}

$pri = $config.winsprimaryserver
$sec = $config.winsSecondaryServer

Write-host "The Current Primary WINS Server on $strComputer is $pri"
Write-host "The Current Secondary WINS Server on $strComputer is $sec"

}

foreach ($strComputer in get-content c:\temp\ServerList.txt)
{
Check-WINS
}

 

 

 

 

Comments

No Comments