Showing results for 
Search instead for 
Did you mean: 

UCS PowerTool - Script Efficiently

Cisco Employee

I wrote a script for a coworker who was at a customer site and needed to collect information from every blade in every UCS in the customer’s data center. The information to be collected was

  • Server
  • Service Profile
  • Adapter Firmware Version
  • CIMC Firmware Version
  • BIOS Version
  • Board Controller Firmware Version
  • Host Firmware Policy

When I started I was looping through the blades and for each blade making a series of cmdlet calls to retrieve the information related to each blade and the script ran very slow. In fact the information retrieval for the items above resulted in 5 Get-Ucs cmdlet calls per blade.  If the UCS had 80 blades there would be 401 Get-Ucs cmdlet calls to retrieve all the information just for that one UCS.  One call to get all the blades, plus 5 times the number of blades in the system of Get-Ucs cmdlet calls (4 Get-UcsFirmwareRunning calls and 1 Get-UcsServiceProfile).  The script worked and it was good enough to get the job done perhaps if it was only going to be run once.

However it could be better, more efficient and take the number of Get-Ucs cmdlet calls from 1 + (5*#blades) per UCS domain to 3 per domain. That’s significantly better and the script will run much much faster. Think about the information that you need to retrieve and if there is a way to get more than just a single item per cmdlet call.

For the list above I know that I can get the blade dn and it’s AssignedToDn with a call to Get-UcsBlade, all the firmware information can be retrieved with a call to Get-UcsFirmwareRunning, finally the host firmware policy can be pulled from Get-UcsServiceProfile. Since I’m getting all the blades and looping through them, why can’t I also get ALL the firmware for all the blades and ALL the service profiles for all the blades and look through the retrieved objects. That is exactly what I did and resulted in the script below.  I am filtering the results of two of my cmdlet calls, which is ok, but you could get all the firmware and all the service profiles, the script would still produce the same results, it just might run a slight bit slower.


Ucs-Blade-Info, get blade info from one ore more UCS Domains and output as CSV .DESCRIPTION

Ucs-Blade-Info, get blade info from one ore more UCS Domains and output as CSV .NOTES

John McDonough, Cisco Systems, Inc. (jomcdono) .PARAMETER Ucs

The UCS hostame or IP address .PARAMETER UcsUser

A UCS user name .PARAMETER UcsPass

The user's password .EXAMPLE

Ucs-Blade-Info.ps1 -Ucs "" -UcsUser admin -UcsPass admin123Ucs-Blade-Info.ps1 -Ucs "," -UcsUser admin -UcsPass admin123 #>

param(   [Parameter(Mandatory=$true,HelpMessage="Enter a comma separated UCS hostname or IP address list")]     [string] $Ucs,   [Parameter(Mandatory=$true,HelpMessage="Enter UCS user")]     [string] $UcsUser,       [Parameter(Mandatory=$true,HelpMessage="Enter UCS user's Password")]     [string] $UcsPass


# Connect to UCS System

  Import-Module CiscoUCSPS -ErrorAction SilentlyContinue   Set-UcsPowerToolConfiguration -SupportMultipleDefaultUcs:$true > $null;   

  $password    = convertto-securestring -Force -AsPlainText $UcsPass;

  $credentials = new-object -typename System.Management.Automation.PSCredential -argumentlist $UcsUser,$password;

  $ucsms = $Ucs.Split(","); 

  Connect-Ucs  $ucsms -Credential $credentials > $null;  

  "UCS,Server,Service profile,Adapter firmware,CIMC firmware,BIOS,Board controller firmware,Host firmware policy";   $Firmware         = Get-UcsFirmwareRunning -Filter "dn -ilike sys/chassis-*/blade-*"; 

  $ServiceProfiles = Get-UcsServiceProfile -AssocState associated; 

  $Blades             = Get-UcsBlade;   $Blades | %{     $Blade  = $_;     $AdapterFirmVer     = $Firmware | ?{$_.dn -like $($Blade.dn + "/*") -and $_.Ucs -eq $Blade.Ucs -and $_.Type -eq "adaptor" -and $_.Deployment -eq "system"} | Select-Object -ExpandProperty Version;   

    $CimcFirmVer        = $Firmware | ?{$_.dn -like $($Blade.dn + "/*") -and $_.Ucs -eq $Blade.Ucs -and $_.Type -eq "blade-controller" -and $_.Deployment -eq "system"} | Select-Object -ExpandProperty Version;   

    $BiosVer            = $Firmware | ?{$_.dn -like $($Blade.dn + "/*") -and $_.Ucs -eq $Blade.Ucs -and $_.Type -eq "blade-bios"} | Select-Object -ExpandProperty Version;   

    $BoardControllerVer = $Firmware | ?{$_.dn -like $($Blade.dn + "/*") -and $_.Ucs -eq $Blade.Ucs -and $_.Type -eq "board-controller"} | Select-Object -ExpandProperty Version;   

    $HostFirmWarePolicy = $ServiceProfiles | ?{$_.dn -eq $Blade.AssignedToDn -and $_.Ucs -eq $Blade.Ucs} | Select-Object -ExpandProperty OperHostFwPolicyName;     $Blade.Ucs + "," + $Blade.dn + "," + $Blade.AssignedToDn + "," + $AdapterFirmVer + "," + $CimcFirmVer + "," + $BiosVer + "," + $BoardControllerVer + "," + $HostFirmWarePolicy;   }   Disconnect-Ucs; 

  Set-UcsPowerToolConfiguration -SupportMultipleDefaultUcs:$false > $null

Hope this helps.


Is there any existing ps1 script to get warranty status of an entire UCS domain?

Cisco Employee

What do you mean by warranty status? Licensing?

I can tell you that any data/information that you see in the UCS Manager interface is retrievable by a script.

There is a PowerShell library for UCS called UCS PowerTool that allows for any information in the UCS interface to be retrieved and managed.




I mean to validate the warranty (hardware) status on the whole environment for support purposes, more specifically, blades, IOMs, Fabric Extenders

Cisco Employee

Warranty information is not stored in the UCS, however you can run scripts to pull the serial numbers for the components you listed.

The UCS PowerTool guide has examples on how to retrieve data from the UCS components.

For example to retrieve blade serial numbers use the Get-UcsBlade cmdlet and select the desired information.

PS C:\> Get-UcsBlade | Select-Object Ucs,Dn,Serial | Format-Table -AutoSize

Ucs    Dn                    Serial

---    --                    ------

g05-sw sys/chassis-1/blade-1 FCH153672ZG

g05-sw sys/chassis-1/blade-2 QCI1413A5IF

g05-sw sys/chassis-1/blade-3 FCH153674BA

g05-sw sys/chassis-1/blade-4 FCH153971BX

g05-sw sys/chassis-1/blade-5 QCI125200JC

g05-sw sys/chassis-1/blade-6 QCI125200K8

g05-sw sys/chassis-1/blade-7 QCI1403A5FE

g05-sw sys/chassis-2/blade-1 QCI133400F8

g05-sw sys/chassis-2/blade-2 QCI133200L9

g05-sw sys/chassis-2/blade-3 QCI133400F7

g05-sw sys/chassis-2/blade-4 QCI133601U3

g05-sw sys/chassis-2/blade-5 QCI133200GW

g05-sw sys/chassis-2/blade-6 QCI133200G1

g05-sw sys/chassis-2/blade-7 FCH1719J6EV

g05-sw sys/chassis-2/blade-8 FCH1719J6X4

g05-sw sys/chassis-3/blade-1 FCH153478UC

g05-sw sys/chassis-3/blade-2 FCH153674RA

g05-sw sys/chassis-3/blade-3 FCH153870HK

g05-sw sys/chassis-3/blade-4 FCH153870BL

g05-sw sys/chassis-3/blade-5 FCH1536740U

g05-sw sys/chassis-5/blade-1 QCI133400BM

g05-sw sys/chassis-5/blade-2 FCH163770QC

g05-sw sys/chassis-5/blade-5 JAF1503AMEJ

g05-sw sys/chassis-5/blade-6 JAF1503BQSP

g05-sw sys/chassis-5/blade-7 JAF1503BQSS

g05-sw sys/chassis-5/blade-8 JAF1503BRAM

For Fabric Interconnects

PS C:\> Get-UcsNetworkElement | Select-Object Ucs,Dn,Serial | Format-Table -AutoSize

Ucs    Dn           Serial

---    --           ------

g05-sw sys/switch-A SSI12480267

g05-sw sys/switch-B SSI12480261

For Chassis

PS C:\> Get-UcsChassis | Select-Object Ucs,Dn,Serial | Format-Table -AutoSize

Ucs    Dn            Serial

---    --            ------

g05-sw sys/chassis-1 FOX1252GG84

g05-sw sys/chassis-2 FOX1332HDZH

g05-sw sys/chassis-3 FOX1503GLF4

g05-sw sys/chassis-5 FOX1428GJJW


PS C:\> Get-UcsIom | Select-Object Ucs,Dn,Serial | Format-Table -AutoSize

Ucs    Dn                   Serial

---    --                   ------

g05-sw sys/chassis-1/slot-1 QCI124900BI

g05-sw sys/chassis-1/slot-2 QCI124900CL

g05-sw sys/chassis-2/slot-1 QCI133602QN

g05-sw sys/chassis-2/slot-2 QCI133602PX

g05-sw sys/chassis-3/slot-1 QCI1449A0HY

g05-sw sys/chassis-3/slot-2 FCH1603711M

g05-sw sys/chassis-5/slot-1 QCI1427A5DE

g05-sw sys/chassis-5/slot-2 QCI1427A5LR

Hope that helps



Thank you very much!! this was very helpful

Content for Community-Ad