prashant1987

PowerShell Script to Add Static IP and DNS Suffixes to the Client system.

Posted on: December 10, 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

1 Response to "PowerShell Script to Add Static IP and DNS Suffixes to the Client system."

Hello, Neat post. There’s an issue along with your
site in web explorer, might test this? IE still is the marketplace chief
and a big section of folks will leave out your magnificent writing due to this problem.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: