Skip to content

Instantly share code, notes, and snippets.

@vMarkusK
Created February 9, 2016 16:16
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 vMarkusK/401fa7d079d59d866e6d to your computer and use it in GitHub Desktop.
Save vMarkusK/401fa7d079d59d866e6d to your computer and use it in GitHub Desktop.
Set Windows Network Name by MAC from CSV
# Importing the CSV-file containing the NIC configuration.
$NICs = Import-Csv "C:\Scripts\NICs.csv" | Where-Object {$_.computername -eq $env:COMPUTERNAME}
foreach ($NIC in $NICs) {
$NetAdapter = Get-NetAdapter | Where-Object {$_.MacAddress -eq $NIC.MAC}
if ($NetAdapter) {
Write-Verbose "Found NIC $($NIC.NIC)"
# Retrieving the network adapter you want to configure.
$NetAdapter = $NetAdapter | Rename-NetAdapter -NewName $NIC.NIC -PassThru
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment