Hello blogosphere! Joe Martin here as a guest on Real World UCS. I’m joining you today to talk about PowerShell with UCSM. A little while ago I was speaking with the one and only Mr. Real World UCS and we were speaking about automation of UCS and I was espousing on the work I had been doing with Cisco PowerTool for PowerShell. I made the bold statement that if I installed a fresh UCS system, plugged in the console to each FI and walked through the initial setup that I could build up a UCS system, monitor it, integrate it with windows, integrate it with the SAN and more using PowerShell. How am I able to say such a bold statement. Well, it’s because UCS was built from the ground up with UCS Manager being an API. When you are in the GUI or the CLI you are just writing to the API. We don’t have a separate API for us and you, it’s the same for everyone. Then we decided to write a tool to auto-generate the PowerShell Cmdlets so we can stay up to date and be very complete in our offering. Over the past year I picked up scripting with PowerShell and have created a number of scripts to help me in my work. These scripts are posted on the Cisco communities site for anyone to download. You can find them here:
In this list of a dozen scripts on the site you will find:
UCS Base Configuration Builder PowerShell Script
This script is three parts. An answer file, a customization script the main build script. By going through the answer file and filling in your desired configuration for UCS, and running the main script, it will build up a UCS system in just a matter of minutes. It has features to make it easy to deploy multiple UCS systems without the fear of overlapping pools. If there are specific capabilities required beyond the build script the customization script can be used to add those. I created this script to allow for rapid, consistent and error free deployments.
UCS Inventory Based User Labels for Servers PowerShell Script
This script will add User Labels to all your blade and rack servers that give a mini-inventory of what is in the blade. such as – B200-M3 / 2 x E5-2650 / 128GB. I created this script to make it easier to locate blades in UCSM
UCS Serial Number Collector PowerShell Script
This script will inventory all of your UCS Domains and create a spreadsheet with that inventory and all the associated serial numbers. I created this script to make sure all of your equipment is covered under SmartNet.
UCS vNIC Statistics PowerShell Script
This script will take a snapshot of all the vNICs on all of your service profiles across multiple UCS Domains and create a report in Microsoft Word of the receive and transmit traffic on them. I created this script as a way to easily grab current traffic information without needing a larger monitoring and reporting tool during initial customer PoCs.
Multi-UCS Domain KVM Launcher PowerShell Script
This script connects to all your UCS Domains and provides a list of all associated Service Profiles so you can simply select it and open a KVM session. I created this script as an ask from a customer to have his NOC be able to easily access the KVM on blades without the hassle of first figuring out which UCSM to connect to.
UCS Available Slots PowerShell Script
This script connects to all of your UCS Domains and provides a document with all the chassis and blades in your environment and lets you know where you have open slots to add blades and what firmware is on that system. I created this script as an ask from a team-mate who said he had a customer who had lots of issues with this in their HP environment. This sealed the deal and they are now purchasing UCS!
UCS Power Control Blades PowerShell Script
This script allows you to turn ON or OFF all the blades in your UCSM domains very easily. Scary I know, but I had a customer who was taking a full datacenter outage and wanted an easy way to power on and off all his blades.
UCS to Windows NIC Rename PowerShell Script
This script renames all the NICs in Windows Server to match the name assigned in UCSM. I wrote this script as I’m now at the point where many of my servers have 8 vNICs that do specific jobs and it was a much easier way to get things setup quickly.
Generate SAN Zones for Cisco or Brocade with UCS PowerShell Script
This script connects to a UCS Domain and will generate all of the Zone Member Aliases, Zones and Zone Sets for that domain. It creates them as single initiator/single target zones and will generate for your A and B fabrics. It will write the output to either text files or can use SSH to connect directly to your SAN equipment and do the configuration. I have tested this with both Cisco MDS and Brocade FOS with great success. It has menus to guide you through the script and gives you the option to build ALL or selected zones.
This final script was how I got invited to guest write on Real World UCS. I was speaking with Craig and he had been using a Perl script to do this. He was manually getting the WWPN info from UCS and then using that data to create the zones. My script does this in one step.
You will also see on the communities site a few other interesting scripts. One is called TEST STUFF and has the framework for a script and you just put your code in the indicated spot. The other one is a script to help you learn PowerTool. It’s the Convertto-UCSCmdlet script. This cmdlet is awesome as it allows you to do something in UCS and then it will spit out the PowerShell command required to complete that task. I use it all the time and then just change the items in it to variables and away I go!
A really nice video of our Microsoft Integrations and PowerShell can be found at the Microsoft Management Site at:
So having such a complete PowerShell library available and all the help from folks on Cisco Communities my job has gotten a lot easier and I wanted to be able to share this with others and since Real World UCS is such an informative and popular site I’m glad that Craig allowed me the honor of guest writing here.
If you have any questions, comments or suggestions you can comment on this post or reach me through Cisco Communities.
Joe Martin, CCIE #5917
Consulting Systems Engineer