Solved

Need Powershell Script for NIC configuration

Posted on 2011-02-23
3
826 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
3 Comments
 
LVL 17

Accepted Solution

by:
Learnctx earned 500 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 70

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
A brief introduction to what I consider to be the best editor for PowerShell.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

932 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now