cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Announcements

543
Views
0
Helpful
3
Replies
Beginner

getting mac address from vnic0

How do I use the powertool to get the mac address of vnic0 which will be my pxeboot nic which I need to make a reservation into dhcp so that the blade can pxeboot the first time

3 REPLIES 3
Highlighted
Enthusiast

Re: getting mac address from vnic0

I am assuming that you are looking to do this with UCSM.  If that's the case then here is a sample script that accomplishes what you want.  Ping me if you have any questions on it.

clear

Write-Output "Script Running..."

Import-Module CiscoUcsPs -ErrorAction Stop

Disconnect-Ucs

$MyUcs = "1.2.3.4" #IP or DNS of UCSM VIP

$ServiceProfile = "ServiceProfile1" #Name of service profile to gather data from"

$Nic = "vnic0" #Name of NIC to gather info about

$Cred = Get-Credential -UserName "admin" -Message "Enter UCSM Login Credentials"

$MyCon = Connect-Ucs -Name $MyUcs -Credential $Cred

if ($MyCon)

{

  Write-Output " Login Successful"

}

else

{

  Write-Output "Login Failed"

  Write-Output " Exiting..."

  exit

}

$PxeNic = Get-UcsServiceProfile -Name $ServiceProfile | Get-UcsVnic -Name $Nic

if (!$PxeNic)

{

  Write-Output ""

  Write-Output "Failed to gather requested NIC information"

  Write-Output " Exiting..."

  Disconnect-Ucs

  exit

}

Write-Output ""

Write-Host "PXE NIC Information-" -NoNewline

$PxeNic | ft -AutoSize -Property Name, Addr, BootDev

Write-Output "Script Complete"

Disconnect-Ucs

Beginner

Re: getting mac address from vnic0

hi

thank you for the script. can i ask how can i get the mac address, and service profile they correspond to?

I did

get-Ucsserviceprofile -UCs ucs | get-ucsvnic -name vnnic0_mgmt_A | ft Name, Addr

but I will also need the service profile name.

also if all I wanted was to get the mac address column without the header, how do I output that to an array or variable?

ex:

get-ucsserviceprofile -UCs ucs | get-ucsvnic -name vnic0_mgmt_A | ft addr

Addr

----

00:25:B5:31:0A:6F

00:25:B5:31:0A:EF

00:25:B5:31:0A:3F

00:25:B5:31:0A:9E

00:25:B5:31:0A:2E

but I dont want the Addr header.

what I was trying to do it get these into an array so I can use netsh or powershell to create dhcp reservations in dhcp.

thanks

Beginner

Re: getting mac address from vnic0

ok I found the flag that does it

get-ucsserviceprofile -UCs ucs | get-ucsvnic -name vmnic0_mgmt_A | ft Addr -HideTableheaders

seems like that did the trick.

CreatePlease to create content
Content for Community-Ad
August's Community Spotlight Awards