The UCS Inventory Script (UIS) is a PowerTool script that retrieves the full configuration of an UCS Manager and displays it in a very readable and portable HTML file for offline use. It also includes some configuration recommendations that come from experience implementing FlexPods. Disclaimer: These recommendations are not official recommendations from Cisco, but taken from experience from the field.

I wrote this script to get an easy overview of UCS installations after completing the initial build. To answer basic questions like “How many port licenses do we have left?” or “Did we create VLAN X?” – when you have no easy connectivity to the management console.

It evolved into a script that gets run periodically to retrieve up to date information and serve as attachment to delivery documents.

Download from GitHub

This script requires an installed PowerShell and Ciscos PowerTool, make sure you have them installed and working before you try running the UCS Inventory Script.

Running the script

You can run the script without arguments; it will ask you for the required input. You can also run the script with the arguments required to run. If you want to run it in a scheduled task, run it with all the arguments.

.\UCS-Inventory-Script-v1.2.ps1 -UCSM UCS-Cluster-01.cosco.com -OutFile UCS-Cluster-01.html -Username ucsUsername -Password ucsPassword

-UCSM: UCS Manager IP address or hostname
-OutFile: The filename used to output the generated HTML
-Username: Username used to login to UCS Manager
-Password: Password used to login to UCS Manager

Multiple UCS Managers

OR you can use a CSV file with the information about multiple UCS Managers. The command looks a bit different in that case:

.\UCS-Inventory-Script.ps1 -CSVFile c:\ucs-domains.csv

-CSVFile: CSV file with info on one or more UCS Manager.

Storing Passwords in CSV

The password of the UCS Manager login is stored in the CSV in an encrypted format. You can generate that encrypted format by using the -GeneratePassword parameter.

.\UCS-Inventory-Script.ps1 -GeneratePassword
Please enter your password: MyPassword
Done! Here's your encrypted password, save this in the CSV:
01000000d0verylongstring

Take that very long string and put it in the “Encrypted Password” column of the CSV.

Logging output

If you’re using this script in an automated fashion, it might be useful to log the scripts output. You can use the -LogFile parameter for that:

.\UCS-Inventory-Script.ps1 -LogFile c:\uis.log

-LogFile: Destination log file.

Example Output

Before you download and run it yourself, you can check here if this will fit your needs. This example contains the output of a testlab with a simple setup.

If there are any changes you’d like to see, more information or other recommendations. Send me a message and I’ll see what I can do to include it!

Changelog

v1.3 - 17-04-2016
 - Added multiple UCS Manager support via a CSV file and logging to a file.

v1.2 - 30-06-2014
- Added a recommendations tab for configuration and health recommendations, taken from experience in the field.
 
v1.1 - 30-12-2013
- Add arguments for the require input data, allow it to run as a scheduled task.

v1.0 - 25-11-2013
- First version; capture every bit of information from UCS Manager I could think of.

 

19 comments on “UCS Inventory Script

  • Hi Martijn,

    Man – that is a great report format for the UCS B Series chassis inventory! I was tasked with acquiring this data via SNMP queries and was struggling to find all of that data in one coherent MIB.

    Are you doing anything with SNMP polling or TRAPs – specifically for the UCS B Series platforms? The reason I ask is that based on my studies so far – it appears that you could use the XML API to gather all the data that one would normally use SNMP polling for.

    Thanks,

    Amir

    • Hi Amir,

      SNMP is typically only used for monitoring. I do use SNMP for that purpose, but then you’re talking about error events, link state changes, hardware failures, etc – not accessing the entire configuration. When talking configuration, always go for the API. XML or Powershell can both work, Powershell is just a bit easier to get working. 😉

  • Hi Martijn,

    Thanks for the reply. It is interesting for me to see the big emphasis on a Windows based scripting language like Powershell when the universe is moving towards everything Linux based.

    My emphasis is going to be on using the UCS Python SDK to develop scripts as our monitoring appliance is Linux based.

    I look forward to your future posts.

    Amir

  • Hi,

    I have requirement for Cisco Inventory details, your scripts suits very well for us. But we needs to run this report on weekly basis. How to avoid password prompt, is there any way we can encrypt the password with script itself.

    Thanks a lot for the script.

    • Hi Dinesh,

      Thanks for your message. As for your question, if you provide the script with a -Username and -Password arguments, it will use those details to login to the UCS Manager and not ask for login details. That way you can use it in a scheduled task (as I do with quite a lot of pods).

      Hope that helps,

  • Hello, That is beautiful script and use it on regular basis. i was wondering if there was a way to run this script on multiple ucs domains and create one combined output file.Thanks

  • I just downloaded the new script version from github (v1.2)
    in order for it to run I had to make the following adjustment on line 54.
    $UCSCredentials = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $Username, ($Password | ConvertTo-SecureString -AsPlainText -Force)
    I was passing UCSM,Username,Password and Output File as parameters via the cli.

    • Hi Chris,

      Good catch, thanks! I’ve just fixed it where it’ll work better both with the manual input and CSV input.

  • Hello,
    I currently have a cisco UCS environment with multiple b200-m4 blades by viewing the console I am able to determine the model adapter E.G Cisco UCS Vic 1380…however I would like to determine the driver installed for each blade. Can your script provide this information?

  • Awesome script. I had to change a bit for our environment as we have some UCS connected C series as well.

    To do that, I just copied line 240 and changed Get-UCSBlade to Get-UcsRackUnit.

  • Hello,

    Fantastic work! Thank you for sharing.

    I did have to make one change to the comparison operator for license use, to indicate all is good if absolute count is >= used count. All port licenses are currently in use and that is okay in my scenario. The script Recommendation output was telling me licensing was not okay since the absolute value was not greater than the used value.

    Was
    if($licenseFabricB_Abs -gt $licenseFabricB_Used)

    Is now
    if($licenseFabricB_Abs -ge $licenseFabricB_Used)

Leave a Reply

Your email address will not be published. Required fields are marked *