prashant1987

Archive for December 2012

NCPA.CPL How many people knows this ? If you are a system administrator , you defininately know this.

It’s indeed a tedious task to go to the NIC ——>Property and put the IP address , DNS Address and DNS Search Suffixes , Wins Address Manually . So , I though lets build a PowerShell script which will make administrator life easy . Below is the script

$IP = Read-Host “Please Enter the IP Address”
$Subnet = Read-host “Please Enter the SubnetMask”
$default = Read-host “Please Enter DefaultGateway”
$dns = “192.168.1.1”,”192.168.1.2″
$DNSsuffix =  “Contoso.com”,”Child.Contoso.com”
$a = Get-WmiObject -Class win32_networkadapterconfiguration -Filter “IPEnabled = true”
$a.EnableStatic($IP , $Subnet)
$a.setGateways($default)
$a.SetDNSServerSearchOrder($dns)
$a.SetWINSServer(“192.162.1.4″,”192.168.1.5”)
invoke-wmimethod -Class win32_networkadapterconfiguration -Name setDNSSuffixSearchOrder -ArgumentList @($DNSSuffixes),$null 

Script should be modified according to your environment. Below are the which one need to modify

$dns = “192.168.1.1”,”192.168.1.2″
$DNSsuffix =  “Contoso.com”,”Child.Contoso.com”
$a.SetWINSServer(“192.162.1.4″,”192.168.1.5”)

Read – host command line will ask you to provide IP address,SubnetMask,Defaultgateway in CMD Prompt

Hope this script will help to remove manual work

Regards,

_Prashant_

 

Advertisements