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

UCS Serial Number Collector PowerShell Script

14883
Views
17
Helpful
36
Comments

I had a customer ask me for a way to easily collect all serial number from a UCS so they could give to their services team to make sure everything was covered under their SmartNet contract.  This is what I came up with.

This script allows you to log into a single or multiple UCS Domains and it will create an Excel spreadsheet of all the devices and their serial numbers.

Prerequisites:
  PowerShell v3 or greater enabled on your client machine
  Network access to your UCSM
  An account on your UCSM
  Excel installed on the client machine
  Cisco PowerTool for PowerShell installed in the client machine

Change Log:

     v0.5 - Initial posted version

     v0.5.01 - Added feature to exit script if you only provide a single domain and domain log in fails or if you are not logged into any UCSM.

     v0.5.02 - Added one more error check for login

     v0.5.03 - Found that older B230's that don't have DIMMs in a slot report their serial number as NO DIMM.  Look for that and ignore entering those into the inventory.

     v0.5.04 - Requires PowerShell V3 and now has a check to ensure you are running it or higher.

     v0.6 - Added a column with the associated Service Profile for the equipment where applicable.

     v0.7 - Added a column with the manufacturing date/time of the equipment where available.

     v0.8 - Added section to collect local hard disk info

     v0.9 - Added built in help.  Command line options.  Standard naming convention.

     v0.9.0.1 - Added support for saved credentials file

     v0.9.10 - Add fields with UCSM Licensing Information

As always, let me know if you have any questions, problems or suggestions.

Joe

Comments
Enthusiast

I just sent you a webex.  I'll hang out here and talk to you soon.


Hi Joe,

I have now a brand new VM with windows 7 and Powershell 4.0 your script work like a charm now.  Many thanks..

Steph.

Hi Joe,

would it be possible to had a field with the server profile currently attached to the physical blades? our inventory is identifying the servers by that name.

Thanks

Stephane.

Enthusiast

Sure.  Let me see what i can do.

Enthusiast

I have just posted version 0.6 which includes a column for Service Profile for devices where applicable.  Please test it out and let me know if everything looks OK.  Please do me a favor a double-check that the Service Profile to equipment is aligning correctly.

hi Joe,

The report is perfect now.

Thanks a lot your the Best.

Stephane.

Cisco Employee

Hi Joe,

I have proceed the script, but it dosnt work. The problem is the excel creation, it start excel but it dosnt create a workbook...

Regards, Tim

Enthusiast

A couple of things to check on Tim.  First is the silly question, but do you have Excel loaded on the box that you are running the script from?  Second is what version of Excel are you using.  I've done most of my testing with 2013 but I know others have used 2010.  Haven't heard of anyone using an older version.  This is to check what is the OS that you are using to run the script from.  There are specific capabilities that require powershell v3, and the script "should" be checking on that before it proceeds.  Lastly you could change line 212 in the script from:

$Excel.Visible = $False

     to

$Excel.Visible = $True


If none of these things help, let me know and we could do a Webex for me to watch what's going on and do some troubleshooting.


Sorry you are having a problem!


Joe

Beginner

Joe,

Any chance for a future version to have an option to pick a specific Chassis to report on?  If not, no worries.  Thanks for sharing this with the community.

Enthusiast

Scott,

Thanks for the feedback on the script.  The way I wrote it would make it difficult to add this capability.  If I see others requesting such a feature I would consider it, but in the meantime, all of my scripts are provided so that your or your organization can use them as examples to customize for their needs.  Good luck and if you decide to tackle modifying the script and have any questions, please reach out to me and I will assist in any way I can.

Community Member

Thanks for the script Joe, great job!!

Would you consider signing the script at all?

I know we can disable scripts from being signed but it is always nice to see authors sign their scripts!!

Instructions are here on how to do that.

http://blogs.technet.com/b/heyscriptingguy/archive/2010/06/17/hey-scripting-guy-how-can-i-sign-windows-powershell-scripts-with-an-enterprise-windows-pki-part-2-of-2.aspx

Beginner

Hey Joe

good evening

loved the sound of this script but when i went to run i got an error stating no path and indicating to this line?

#Change directory to the script root

cd $PSScriptRoot

any ideas?

cheers

mark

Enthusiast

Mark,

     It seems that this object is not receiving it's value.  This is a system object that is automatically provided a value with the directory location of the script.  The only time I've not seen this filled in is if I've copied some contents into a powershell editor and run them without saving them first.  Beyond that we'd have to debug your environment which I'm will to do.  If you'd like to do that we can schedule a Webex and look over your environment.  I have lots of folks using this script without issue so I'm thinking this is a unique situation with your environment.  Let me know if you want to do this.

Community Member

This is a fantastic script! Question...what would it take to split this script into 2 separate pieces? Like the first comment posted, many of our management boxes do not have Excel on them. I was thinking that it would be a cool option to split the script into 2 pieces, the first piece collects all the data into a CSV and the second piece actually process the data into the tables within Excel. That way, we can gather the data within a secure environment via the standard PowerShell plugins and then process teh data from a local machine with Excel installed.

Thoughts? Too complex?

Thanks for your great work!

Enthusiast

It wouldn't be difficult to change the script to output to a CSV file rather than Excel directly.  I wouldn't see a need to write a second script to process the data.  The only thing you loose with having the data collected and then opened in Excel...as Excel can directly open a CSV...is the formatting.  Things like the bolded and underlined titles and the cell widths.

I post these scripts as examples and encourage folks to use the base work and customize it for their requirements.  Please make any changes you'd like.  I'll also encourage you to post your results back here on communities so the broader public can take advantage of it

CreatePlease to create content
Content for Community-Ad
August's Community Spotlight Awards
This widget could not be displayed.