Last active
March 4, 2021 01:04
-
-
Save Pyromaniaxxx/dca422af303b45a8d84ffa9548565049 to your computer and use it in GitHub Desktop.
NIC 名を Etx0x に揃えるスクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#get list | |
$AdapterList = @(Get-NetAdapter | Where-Object {$_.InterfaceDescription -match 'Eth' } | Select-Object MacAddress,Name,InterfaceDescription|Sort-Object MacAddress); | |
$AdapterList; | |
#change name | |
for ($i = 0; $i -lt $AdapterList.Count; $i++) | |
{ | |
if ($AdapterList[$i].InterfaceDescription.IndexOf("SFP") -eq -1) | |
{ | |
$newname = "Eth0{0}-T" -f ($i+1); | |
}else { | |
$newname = "Eth0{0}-SFP" -f ($i+1); | |
} | |
$AdapterList[$i] | Rename-NetAdapter -NewName $newname; | |
#Write-Verbose -Message (" Change network adapoter Name : {0}" -f ($newname ); | |
} | |
#get list | |
"------" | |
Get-NetAdapter | Where-Object {$_.InterfaceDescription -match 'Eth' } | Select-Object Name,MacAddress,InterfaceDescription|Sort-Object Name | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment