Archive for the ‘Rename NIC’ Category

PowerShell Function Set-NetInterfaceName

August 13, 2008

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: }