Skip to content

Instantly share code, notes, and snippets.

@alexsaezm
Created November 5, 2013 12:43
Show Gist options
  • Select an option

  • Save alexsaezm/7318482 to your computer and use it in GitHub Desktop.

Select an option

Save alexsaezm/7318482 to your computer and use it in GitHub Desktop.
function GetStuff {
$TargetMac = "MAC GOES HERE"
$NetworkAdapters = gwmi Win32_NetworkAdapter
foreach ($NetworkAdapter in $NetworkAdapters) {
if($NetworkAdapter.MACAddress -eq $TargetMac -and $NetworkAdapter.ServiceName -eq "e1kexpress") {
write-host "MACAddress:" $NetworkAdapter.MACAddress
$DeviceID = $NetworkAdapter.DeviceID
ConfigMe($DeviceID)
}
}
}
function ConfigMe([string]$DeviceID) {
write-host $DeviceID
$NetworkAdapterConfigurations = Get-WmiObject Win32_NetworkAdapterConfiguration
foreach ($NetworkAdapterConfiguration in $NetworkAdapterConfigurations) {
if ($NetworkAdapterConfiguration.Index -eq $DeviceID) {
write-host $NetworkAdapterConfiguration.IPAddress
}
}
}
GetStuff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment