PowerShell Function Set-NetInterfaceName

Now that you are able to set an IP address given a name of a network interface, you may want to change that name.

Here’s a quick little function to do that.

   1: function Set-InterfaceName {
   2:         param(  
   3:                 [string]$oldName,
   4:                 [string]$newName
   5:          )
   6:         
   7:         $NicInterfaceName = gwmi Win32_NetworkAdapter | where {$_.netconnectionid -eq $oldName}
   8:         $NicInterfaceName.netconnectionid = $newName
   9:         $NicInterfaceName.put()
  10:         
  11: }
Advertisements

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: