cancel
Showing results for 
Search instead for 
Did you mean: 
cancel

UcsInventory - creates an Excel spreadsheet with the UCS hardware inventory

20006
Views
27
Helpful
26
Comments

This PowerTool script connects to one or more UCS domains querying it/them for hardware details on fabric interconnects, chassis, blades and rackmount servers. Using that information it generates an Excel spreadsheet with one sheet per UCS domain, presenting the inventory in the form of an outline. Besides model, part number, etc. it also lists for each element the serial number and firmware version.

 

There are a few command line parameters, the most important being '-show' which controls the level of detail you get to see. At level one you see only an overview of chassis's, blades and servers. At two the scripts adds CPUs and memory, then all the way up to five where you will get detailed info on each and every DIMM. The following example is at level three.

 

UcsInventoryPE.png

 

July 2018 update. Finally I put in the time to update the script from PowerTool version 1.X to 2.X, which also allows for PowerShell version 3. Sorry it took so long. Another big improvement is the change to using the UCS class "equipmentManufacturingDef" to get better naming and such. By doing that I could remove from the script all the manually created tables (which had to be maintained by hand) that were generating proper CPU names and similar stuff. The result is still not perfect but that is because the UCS DOM is after nine years more than a little messy.

 

Couple of technical things to be aware of. You need to have Microsoft Office installed on the system running the script. Also, don't install the script in C:\ because for some reason the script doesn't have write access there, put it instead in some user directory. This script will store the data retrieved from UCS Manager in a bunch of csv-files in "C:\Temp". Finally there is the '-v' flag with which you can follow the progress of the script.

 

A fork of this script will fetch an inventory of C-Series and E-Series servers that are not managed by UCS-Manager. You can get it at https://communities.cisco.com/docs/DOC-57125 .

 

Willem van Schaik

<wschaik@cisco.com>

Calgary, Jan 2015, Jul 2018

Comments
Beginner

Sean, the UcsInventory script is a dual stage process. First stage is to collect UCS data from the FI's and then store that in a bunch of .csv files. The second stage is taking this data to create an Excel spreadsheet. My suspicion is that it could have to do with your version of Excel. But tough to say with just the information in your message.

Community Member

Thanks. Office 2010. I thought as much after looking at the script, it doesn't appear to do the second half. What version was it written for?

Beginner

Office2010 should be no problem

maybe you can "play around" with the line [ $xlsFile = $PSScriptRoot + "\UcsInventory.xlsx" ]

for example replace the $PSScriptRoot variable with a hard coded pathname

Community Member

wschaik Not sure if you are still looking at this as it is over a year old. But wanted to say thank you.

there is one issue though when you get into Chassis being 10-19 or 20-29 and so on it will add the equipment like Fans from Chassis 11 to Chassis 1 List and so on for 20's to Chassis 2 list.   I have been dissecting your code but still a

Beginner

thanks for letting me know, I will take a look and fix it

--

Willem van Schaik, UCS Consulting Systems Engineer

wschaik@cisco.com +1-403-606-9010 (mobile)

. : | : . . : | : . Cisco Systems, Calgary AB, Canada

Beginner

Thanks for the update.  There seems to be a bug (even in v2) where rack mounts and blades get merged together for Chassis 1 and server 1.  We just added our 20 rack mount and I notice that it does it to Server 2 now as well.  We have 14 Chassis and 21 Rack mounts in the domain I am using as the example.Rack2.PNGChassis1.PNG.  

 

Rack1.PNG

Beginner

Sorry, I just noticed the guy above me reported it already.

Beginner

I am new to powertool and trying to run this script , It keeps giving me error "Can't create Excel spreadsheet, is Microsoft Office installed?" however I can open the spreadsheet tpo prove I have excel installed .

Looking at scrip I found it's calling spreadsheet ucsinventory "$xlsFile = $PSScriptRoot + "\UcsInventory.xlsx"" however ZIP file has ucsinventoryPE, giving that I renamed the file to ucsinventory.xlsx and ran script again , it gave me same error but this time deleted ucsinventory file from directory,

can somebody advise where I am doing wrong ?

Beginner

It keeps giving me Excel error , can somebody help , I already have excel installed and I have RW access to folder 

I think it exiting once it hits below lines 

# Create Excel spreadsheet
Try {
$excelApp = New-Object -comobject Excel.Application
$excelApp.Visible = $False
$excelApp.sheetsInNewWorkbook = $ucsArray.Count
$workbook = $excelApp.Workbooks.Add()
}
Catch {
Write-Host "Can't create Excel spreadsheet, is Microsoft Office installed?"
# Write-Host "Error equals: ${Error}"
Write-Host "Exiting..."
Write-Host ""
exit

 

Cisco Employee

@ srashidi,

 

We tried the script in 2 different machines. One having Excel 2013 and one having Excel 2016.

On both machines script has worked fine and Inventory sheet is created.

Seems to be an issue with excel installation or permission in your machine.

 

To see the exact error thrown by PowerShell while creating the excel object, un-comment the 3rd line from below piece of code in the script ( line number 128 in the script) and then execute the same.

This should capture the exact error thrown by the system.

 

Catch {
Write-Host "Can't create Excel spreadsheet, is Microsoft Office installed?"
# Write-Host "Error equals: ${Error}"
Write-Host "Exiting..."
Write-Host ""
exit

Cisco Employee

@ srashidi,

 

We tried the script in 2 different machines. One having Excel 2013 and one having Excel 2016.

On both machines script has worked fine and Inventory sheet is created.

Seems to be an issue with excel installation or permission in your machine.

 

To see the exact error thrown by PowerShell while creating the excel object, un-comment the 3rd line from below piece of code in the script ( line number 128 in the script) and then execute the same.

This should capture the exact error thrown by the system.

 

Catch {
Write-Host "Can't create Excel spreadsheet, is Microsoft Office installed?"
# Write-Host "Error equals: ${Error}"
Write-Host "Exiting..."
Write-Host ""
exit

CreatePlease to create content
Content for Community-Ad
August's Community Spotlight Awards