Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Need Powershell Script for NIC configuration

Posted on 2011-02-23
3
Medium Priority
?
834 Views
Last Modified: 2012-05-11
I'm looking for a powershell script that will configure a Windows Server 2008 NIC.  

The script should prompt me to enter the nic configuration information, such as IP address, subnet mask, gateway, primary dns, secondary dns, wins, and so forth.  The script should then configure the nic with the input that I provided.  Ideally, it would then issue an automatic reboot of the server.

I have a lot of virtual servers that are being moved to a new subnet.  Once they are moved to the new subnet, I'm going to access the machine using the VMware console.  I'm then going to log in and reconfigure the nics.  This is why I ask for help with a script.

Any help or useful suggestions will be greatly appreciated.


0
Comment
Question by:xi2pay
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 17

Accepted Solution

by:
Learnctx earned 2000 total points
ID: 34966902
Try this.

Usage: Set-Network -ip 1.1.1.1 -mask 255.255.255.0 -dns1 1.1.1.2 -dns2 1.1.1.3 -gateway 1.1.1.254
function Set-Network {

	param(
		[string]$ip,
		[string]$mask,
		[string]$gateway,
		[string]$dns1,
		[string]$dns2,
	)

	if ($dns1 -And $dns2)
	{
		$dns = "$($dns1),$($dns2)"
	}
	elseif ($dns1)
	{
		$dns = $dns1
	}


	$objNetAdaConf = Get-WmiObject Win32_NetworkAdapterConfiguration -Filter "IPEnabled='True'"
	[void]$objNetAdaConf.EnableStatic($ip, $mask)
	[void]$objNetAdaConf.SetGateways($gateway)
	[void]$objNetAdaConf.SetDNSServerSearchOrder($dns)
}

Open in new window

0
 
LVL 71

Expert Comment

by:Chris Dent
ID: 35687958
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

670 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