Tuesday, August 30, 2011

Powershell Script to automate WINS install/configuration

Here's a  short powershell script I wrote that will automate the installation of WINS server and configure a two way replication partnership.


Import-Module Servermanager
Add-WindowsFeature WINS-Server
[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic') | Out-Null
$computer = [Microsoft.VisualBasic.Interaction]::InputBox("Enter Host of Replication Partner", "Computer", "$env:computername")
$myip=((ipconfig | findstr [0-9].\.)[0]).Split()[-1]

$partner=([System.Net.Dns]::GetHostaddresses("$computer".split('.')[0]))[0].ipaddresstostring
netsh wins server $myip add partner Server=$partner type=2
netsh wins server $partner add partner Server=$myip type=2

No comments:

Post a Comment