UCS Inventory Script

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:

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!


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.



  1. 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.



    • Martijn

      July 20, 2014 at 10:02

      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. 😉

  2. 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.


  3. Thanks for the script, using it at work. Really great.

  4. 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.

    • Martijn

      October 18, 2015 at 16:30

      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,

  5. Is it possible to email this output to a email address ?

  6. Thanks Martijn,
    Thats helps….

  7. 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

    • Martijn

      March 21, 2016 at 16:59

      Hi Amar, thanks! Multiple UCS domains is on my wish list, but I can’t say when that’ll be.

  8. 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.

    • Martijn

      April 21, 2016 at 09:15

      Hi Chris,

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

  9. Jason Jones

    May 17, 2016 at 17:36

    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?

  10. 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.

  11. 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.

    if($licenseFabricB_Abs -gt $licenseFabricB_Used)

    Is now
    if($licenseFabricB_Abs -ge $licenseFabricB_Used)

  12. Hi guys, i hope you don’t mind asking but I’m having a nightmare getting this script to run, am i do something wrong
    Windows PowerShell
    Copyright (C) 2012 Microsoft Corporation. All rights reserved.

    PS C:\Users\Training\Desktop\v1.0> .\UCS-Inventory-Script.ps1 -UCSM
    At C:\Users\Training\Desktop\v1.0\UCS-Inventory-Script.ps1:126 char:19
    + ~
    The ‘<' operator is reserved for future use.
    At C:\Users\Training\Desktop\v1.0\UCS-Inventory-Script.ps1:130 char:19
    + ~
    The ‘<' operator is reserved for future use.
    At C:\Users\Training\Desktop\v1.0\UCS-Inventory-Script.ps1:135 char:19
    + ~
    The ‘<' operator is reserved for future use.
    At C:\Users\Training\Desktop\v1.0\UCS-Inventory-Script.ps1:140 char:19
    + ~
    The ‘<' operator is reserved for future use.
    At C:\Users\Training\Desktop\v1.0\UCS-Inventory-Script.ps1:144 char:19
    + ~
    The ‘
    + ~
    Ampersand not allowed. The & operator is reserved for future use; use “&” to
    pass ampersand as a string.
    At C:\Users\Training\Desktop\v1.0\UCS-Inventory-Script.ps1:5305 char:10
    + ~
    The ‘<' operator is reserved for future use.
    At C:\Users\Training\Desktop\v1.0\UCS-Inventory-Script.ps1:5320 char:24
    + © 2017 <span title="0.25423s from
    unicorn-1883663271 …
    + ~
    Ampersand not allowed. The & operator is reserved for future use; use "&" to
    pass ampersand as a string.
    At C:\Users\Training\Desktop\v1.0\UCS-Inventory-Script.ps1:5320 char:36
    + © 2017 <span title="0.25423s from
    unicorn-1883663271 …
    + ~
    The '<' operator is reserved for future use.
    At C:\Users\Training\Desktop\v1.0\UCS-Inventory-Script.ps1:5320 char:42
    + © 2017 GitHub’ in expression or statement.
    Not all parse errors were reported. Correct the reported errors and try again.
    + CategoryInfo : ParserError: (:) [], ParseException
    + FullyQualifiedErrorId : RedirectionNotSupported

    PS C:\Users\Training\Desktop\v1.0>

    any help greatly appreciated

    • Martijn

      August 25, 2017 at 20:42

      The encoding of the script file seems to be off. Did you copy and paste it onto the server you’re trying to run it? Try downloading it directly, or (if a firewall blocks that) download it somewhere else and copy over the entire file, instead of copy pasting the text.

  13. Thanks for replying,
    i downloaded the file (UCS-Inventory-Script.ps1) from the download link and tried to run it, the output is from the shell after i try to run the file, i must be missing something but i just can’t figure out what

  14. You sir are amazing, as you can probably tell I’m new to this and as you rightly said i failed to copy the file correctly
    Many thanks for taking the time to help me

  15. Generated the secure password via the -GeneratePassword switch and put it into the CSV file. I’m getting the following two errors:

    ConvertTo-SecureString : Input string was not in a correct format.
    At C:\scripts\ucs\UCS-Inventory-Script.ps1:86 char:123
    + … dential -argumentlist $Username, ($Password | ConvertTo-SecureString)
    + ~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [ConvertTo-SecureString], FormatException
    + FullyQualifiedErrorId : System.FormatException,Microsoft.PowerShell.Commands.ConvertToSecureStringCommand

    Connect-Ucs : Cannot bind argument to parameter ‘Credential’ because it is null.
    At C:\scripts\ucs\UCS-Inventory-Script.ps1:103 char:46
    + $ucsc = Connect-Ucs -Name $UCSM -Credential $UCSCredentials
    + ~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidData: (:) [Connect-Ucs], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Cisco.Ucsm.Cmdlets.ConnectUcs

    Any ideas?

  16. Just coming across this very useful script. I’ve made some enhancements if you are interested.
    Slight efficiencies in param checking in various places.
    Added the -Credential parameter to pass already set credentials. (Could still be extended more to be useful with spreadsheet use.)
    Also wrote in a function to manage credentials whether passed with -Credential, passed with -Username and/or -Password, or collected at runtime.
    Email me if you want the update.

  17. trying to run the script against UCS managers that aren’t using ‘native’ as the UCS authentication domain, but keep getting authentication errors. I’ve tried specifying ‘ucs-XXX\uid’ as the user, but auth keeps failing. Is there any other way to specify the UCS auth domain?

Leave a Reply

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

© 2024 Lostdomain

Theme by Anders NorénUp ↑