?
Solved

Powershell Script

Posted on 2011-03-19
7
Medium Priority
?
835 Views
Last Modified: 2012-05-11
Hi Experts,

Can anyone help me out with a task I need to implement?

I have no real experience with scripting, but one of our clients needs me to renumber a bunch of his server NIC's and asked me to do it in Powershell.

Any help would be appreciated
0
Comment
Question by:jh270
[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
  • 4
  • 3
7 Comments
 
LVL 12

Expert Comment

by:Amick
ID: 35173579
Are you looking for something like this:
$Shell = New-Object -com shell.application
$NetCons = $Shell.Namespace(0x31)
$NetCons.Items() | 
  where {$_.Name -like 'Local Area Connection*'} | 
     foreach{$AdapName=$_.Name; get-WmiObject -class Win32_NetworkAdapter | 
			where-Object {$_.NetConnectionID -eq $AdapName} | 
				foreach {$MAC=$_.MacAddress}
					$_.Name=$MAC.replace(':','.')
				}

Open in new window

Rename Network Adapters to their MAC Addresses
from: http://www.delltechcenter.com/page/Helpful+PowerShell+Scripts
0
 

Author Comment

by:jh270
ID: 35173642
I wish I could tell you if that was it :-)

If this script will renumber multiple NICs, then yea that should do it. The customer has about 30 VM's that he wants to renumber. These VM's are new, but the IP addresses are already assigned to other VMs that he is going to de-commision. So, he's looking to replace the IP's from the old VM's to the new ones, and asked that I script it for the sake of efficiency.
0
 
LVL 12

Expert Comment

by:Amick
ID: 35173709
Then, no, the above code doesn't do what you want.
0
Connect further...control easier

With the ATEN CE624, you can now enjoy a high-quality visual experience powered by HDBaseT technology and the convenience of a single Cat6 cable to transmit uncompressed video with zero latency and multi-streaming for dual-view applications where remote access is required.

 
LVL 12

Accepted Solution

by:
Amick earned 750 total points
ID: 35175353
This  script that reassigns IPs among other functions:
http://gallery.technet.microsoft.com/scriptcenter/3d5ae334-1d75-4cea-8079-78c6bd836faf

The value is that it can be used as is, if the job is more important than the environment in which it executes.  Study the code to find the objects that need to be manipulated and where they can be found.

You might also look at Microsoft's free scripting tools including
PowerShell Scriptomatic
and
WMI Code Creator

Have you thought what steps you might take to do this project manually? If so, would you please list them. That way any residual confusion over what you are trying to do is eliminated.
0
 
LVL 12

Expert Comment

by:Amick
ID: 35175440
PowerShell code to Change IP assigned to a MAC Address

#change/assign $hostIp to a valid IP address
(gwmi -Class Win32_NetworkAdapterConfiguration | where { $_.IpAddress -eq $hostIp }).MACAddress

Open in new window


There is more detail at the site.
0
 

Author Closing Comment

by:jh270
ID: 35177811
This is close, but my posting explains what i'm trying to do, and this is still off by a bit.
0
 

Author Comment

by:jh270
ID: 35177845
I'm suprised that finding such a script is such a problem. It seems that renumbering a large number of servers isn't all that uncommon, and considering that VMs are now so prevalent, you'd think that this scenario would be more common.

Amick,
Manually, I would just get all my IP's and then assign them to the new VM's, and then disable the old NIC's one by one as I assigned the new ones, but since our customer asked that it be scripted, I thought it would be relatively simple to find such a script since this doesn't seem that far outside the norm. I guess I was wrong, and since I know little about scripting and have no experience coding, I can't parse through the deeper aspects of a simple script like the one you mention above and reconfigure it to do something quite a bit more complex.

I have been to the links you mentioned. I crawled all over them yesterday, but like I said, i'm no scripter, so other than using one of the simple ones, I would have no clue as to what to do to build it further.

Thanks for you time.
0

Featured Post

Manage your data center from practically anywhere

The KN8164V features HD resolution of 1920 x 1200, FIPS 140-2 with level 1 security standards and virtual media transmissions at twice the speed. Built for reliability, the KN series provides local console and remote over IP access, ensuring 24/7 availability to all servers.

Question has a verified solution.

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

I was prompted to write this article after the recent World-Wide Ransomware outbreak. For years now, System Administrators around the world have used the excuse of "Waiting a Bit" before applying Security Patch Updates. This type of reasoning to me …
A small collection of useful tips and tricks for Windows 10 users that I decided to write as a result of recent questions that were asked and answered at Experts Exchange. Two short video tutorials included. Enjoy..
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

765 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