PoshCode Archive  Artifact Content

Artifact 2a5486b955d897562edb5a28ddeae5b7957aaa48f8f4e5906f87ee0c373070fd:

  • File Rename-NICs.ps1 — part of check-in [28741266c5] at 2018-06-10 12:57:23 on branch trunk — Rename Network Adapters to their MAC Addresses (user: powershelluser size: 726)

# encoding: ascii
# api: powershell
# title: Rename NICs
# description: Rename Network Adapters to their MAC Addresses
# version: 0.1
# type: class
# author: powershelluser
# license: CC0
# x-poshcode-id: 1452
# x-archived: 2012-06-08T04:15:49
# x-published: 2012-11-03T17:45:00
#
# from: http://www.delltechcenter.com/page/Helpful+PowerShell+Scripts
#
$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(':','.')
				}