Skip to content

Instantly share code, notes, and snippets.

@Pyromaniaxxx
Last active March 4, 2021 01:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pyromaniaxxx/dca422af303b45a8d84ffa9548565049 to your computer and use it in GitHub Desktop.
Save Pyromaniaxxx/dca422af303b45a8d84ffa9548565049 to your computer and use it in GitHub Desktop.
NIC 名を Etx0x に揃えるスクリプト
#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