PoshCode Logo PowerShell Code Repository

Get-UcsServerVlan by halr9000 4 years ago
View followups from Viswanath | embed code: <script type="text/javascript" src="http://PoshCode.org/embed/3391"></script>download | new post

Uses the Cisco UCS PowerTool (http://developer.cisco.com/web/unifiedcomputing/pshell-download) to list server names, NICs and associated VLANs. Goes well piped out to format-table -auto Server, Vnic, Vlan

  1. function Get-UcsServerVlan {
  2.     Get-UcsServiceProfile | Foreach-Object {
  3.         $sp = $_
  4.         $sp | Get-UcsVnic | Foreach-Object {
  5.             $vn = $_
  6.             $vn | Get-UcsVnicInterface | Foreach-Object {
  7.                 $output = New-Object psobject –property @{
  8.                     Server = $sp.Name
  9.                     Vnic = $vn.name
  10.                     Vlan = $_.name
  11.                 }
  12.                 Write-Output $output
  13.             }
  14.         }
  15.     }
  16. }

Submit a correction or amendment below (
click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:


Remember me