How to Find MAC Addresse of NIC in Windows Team This article describes how to get the MAC addresses of all member Network Interface Cards (NICs)

There are lot of instances where the network communications fail when we are teaming up the incorrect network interfaces. Especially when the team members are the partitions of a virtual partition capable Converged Network Adapter (CNA), we need to make sure that we are teaming up correct partitions from different physical ports for redundancy and proper VLAN traffic. In such situations, the primary troubleshooting step related to network team’s connectivity issue is to validate the network team members.

The easiest way to ensure this is to compare the unique attributes of the partitioned interfaces with the data in the network card BIOS or out-of-band management tools (like iDRAC, ILO etc) or other baseboard management controllers. Media Access Control (MAC) addresses of the partitioned interfaces seen by the Operating System are the easiest and reliable unique identifiers in this scenario as the names for the interfaces will be different for different network cards.

The default available option to get the member NIC’s MAC address is to use the PowerShell command Get-NetAdapter <member NIC name>. For that we have to manually find the native teams in the server, their member NICs and then the MAC addresses of the member NICs.

The following short PowerShell script will automate this process and will list down the MAC addresses of the member NICs of all the native windows teams available in the server. The advantage with the below script is that it can be used on any Windows 2012 or Windows 2012 R2 servers without any modifications/inputs.

Script:

foreach ($i in ((Get-NetLbfoTeam).name))
{
Write-Host “`nTeam Name – “$i`n”Team Members: ”
Get-NetAdapter (Get-NetLbfoTeamMember -Team $i).Name | Format-Table
}

The best way is to open notepad, copy and paste this script, then save the file as ‘Save As’ > Select ‘All files’ > then name the file ‘nic.ps1’ > destination > where you want

Open Powershell, and run the file .ps1 from it:

MAC_Addresses_NIC_Team_2012
MAC_Addresses_NIC_Team_2012

Related Article: Technet Microsoft

Inviare una Email in formato HTML con Powershell Formattate HTML e con Immagini nel corpo dell'email

[code language="powershell"]
function sendMail
{
Write-Host “Sending Email”

$Image = “Path1”
$Image1 = “Path2”

#Embed Image
$att1 = new-object Net.Mail.Attachment($Image)
$att1.ContentType.MediaType = “image/png”
$att1.ContentId = “Attachment”
$att2 = new-object Net.Mail.Attachment($Image1)
$att2.ContentType.MediaType = “image/png”
$att2.ContentId = “Attachment1”

#Mail body
$body = “<table style='width:100%'>
<tr>
<td align=left valign=top><img src='cid:Attachment' /></td>
</tr>
<tr>
<td align=left valign=top>My Test<br>
Directory: <a href='url'>Link</a><br><br></td>
</tr>
<tr>
<td align=left valign=top>Email inviata $(Get-Date -format F) <br><br></td> 
</tr>
<tr>
<td align=left valign=top>Do-Not Reply<br></td> 
</tr>
<tr>
<td align=left valign=top><img src='cid:Attachment1' /></td> 
</tr>
</table>”

#SMTP server name
$smtpServer = “server.smtp...”

#Creating a Mail object
$msg = new-object Net.Mail.MailMessage

#Add attachment to the mail
$msg.Attachments.Add($att1)
$msg.Attachments.Add($att2)

#Creating SMTP server object
$smtp = new-object Net.Mail.SmtpClient($smtpServer)

#Email structure 
$msg.From = “email@sender.ext“
$msg.ReplyTo = “reply@sender.ext“
$msg.To.Add(“emailto@sender.ext“)
$msg.subject = “Subject Email”
$msg.body = $body
$msg.IsBodyHTML = $true

#Sending email 
$smtp.Send($msg)
}

#Calling function
sendMail

exit
[/code]

Lo script in Poweshell appena mostrato genera una email con queste caratteristiche:

  • Testo Formattato in HTML, e tabella all’interno (risulta più ‘responsive’, anche se non lo è);
  • 2 immagini allegate ed inserite nel corpo della email (si possono inserire N immagini, bisogna associare l’attributo ‘attX’ ‘ImageX’ e AttachmentX)
    #Embed Image
    $attx = new-object Net.Mail.Attachment($ImageX)
    $attx.ContentType.MediaType = “image/png”
    $attx.ContentId = “Attachment”;
  • Un link nel corpo dell’email (può essere una URL si un sito, o un link locale;
  • La data cui è stata generata l’email (formattata giorno-mese-anno-ora-minuti-secondi);
  • Attributi email: indirizzo del mittente, indirizzo per reply (può essere diverso dal mittente), indirizzo/i dei destinatari;
  • Server smtp non autenticato, su porta 25 e sena cifratura.

Lo script può essere schedulato normalmente con lo scheduler di Windows, funziona con tutte le versioni di powershell (consigliata comunque sempre l’ultima).

Il consiglio è di non inserire ne’ troppe immagini e ne’ troppo grandi. Quindi rimanere con un numero inferiore a 5, con formati png e con una grandezza di non più di 10kB.