VMware Cloud Community
Compton94
Contributor
Contributor
Jump to solution

N1K or DVS info on a ESXi Host

We are trying to find a way to see if an ESXi host is on a N1K or standard switch as we are moving all systems to N1K and need to verify it was completed.  We thought of using the Get-CDP but since we are using Cisco UCS blades it always comes back Cisco Nexus.  Does anyone have any thoughts on how this can be done?

thanks in advance.

Matt

1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

I don't have a N1K handy right now, but does this list the connected ESXi hosts per N1K ?

foreach($dvs in Get-VDSwitch){
 
Get-View -Id ($dvs.ExtensionData.Config.Host | %{
   
$_.Config.Host}) |
 
Select @{N="dvSw";E={$dvs.Name}},@{N="ESX";E={$_.Name}}

}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

9 Replies
jason89s
Contributor
Contributor
Jump to solution

We're also having a problem accomplishing the same task when trying to get information about an n1k on a specific node.  Trying the other tricks around the Internet don't seem to work when trying to poll data from a specific node, but rather only at the VC level.

Get-VDSwitch -VMHost myhost.example.com

Get-VDSwitch  Unable to cast object of type 'VMware.Vim.DistributedVirtualSwitch' to type 'VMware.Vim.VmwareDistributedVirtualSwitch'.

At line:1 char:13

+ Get-VDSwitch <<<<  -VMHost myhost.example.com

    + CategoryInfo          : NotSpecified: (:) [Get-VDSwitch], VimException

    + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.Vds.Commands.GetVDSwitch

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Isn't that to be expected, since dvSwitch is a vCenter feature ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
jason89s
Contributor
Contributor
Jump to solution

The intention is to put it in a try/catch to see if an ESXi node is joined to an n1k along the lines of what Compton94 is trying to do.  Do you have a suggestion for how to check if an ESXi server is joined to an n1k?

0 Kudos
LucD
Leadership
Leadership
Jump to solution

I don't have a N1K handy right now, but does this list the connected ESXi hosts per N1K ?

foreach($dvs in Get-VDSwitch){
 
Get-View -Id ($dvs.ExtensionData.Config.Host | %{
   
$_.Config.Host}) |
 
Select @{N="dvSw";E={$dvs.Name}},@{N="ESX";E={$_.Name}}

}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

jason89s
Contributor
Contributor
Jump to solution

This looks like its going to work great, thanks LucD!

0 Kudos
Compton94
Contributor
Contributor
Jump to solution

Thanks LucD, I am trying it out now and will update and let you know...

thanks

Matt

0 Kudos
Compton94
Contributor
Contributor
Jump to solution

LucD,

thanks this is working the way that I want.  thanks a lot.

Matt

0 Kudos
grasshopper
Virtuoso
Virtuoso
Jump to solution

Nice one LucD!  I tested this on a wide variety of 1000v deployments (vCenter 5.0 and 5.1, and ESXi hosts at 4.1 and 5.1).  Works perfectly.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Thanks for the feedback.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos