Hello again, everyone! For my fifth post for this year’s #BlogtoberTech challenge, I decided to share a script I recently wrote that seeks out virtual machines in a vSphere environment based on a specific virtual hardware version. This sort of ties in with the BIOS and UEFI scripts I wrote earlier in the year to seek out VMs that may still be open to the Spectre/Meltdown vulnerabilities (virtual hardware version 8 or older). Or perhaps someone wants to seek out VMs that may be good candidates to enable Secure Boot (virtual hardware 13 or newer with EFI boot firmware configured).
In the initial version of this script, I ask the user to pick the vCenter to connect to, the datacenter object to scan, and then the virtual hardware version to seek out. If VMs of virtual hardware n are found, the user has the option of exporting the results to a CSV file. Otherwise, a dialog box will appear (via Out-GridView) that shows the results of the can. If, however, no VMs with a specified virtual hardware version are found, it will simply let the user know that “No VMs with virtual hardware n were found.”
As usual, the latest version of this script can be found over on my GitHub page, but here’s the script as it was written at the time of this post:
Continue reading “PowerCLI: Find VMs Based on Virtual Hardware Version”
Hey everyone! I wanted to spread the word about my upcoming presentation at the Central PA VMUG on Thursday, November 1st in State College! Last year, I spoke at the Pittsburgh VMUG on the topic of PowerCLI and my journey into scripting. This year, I plan on revisiting that presentation with several new updates and maybe even do live demo (assuming I can get my home lab completely set up and configured in time)! Plus, I’m looking forward to catching up with the Central PA VMUG crew as well as meeting many others in the #vCommunity!
For those who may not know, October 2017 was my first time ever presenting at a local VMUG meeting. In fact, I wasn’t really engaged in the VMware Community all that much until about April 2017, when I started my blog and began using Twitter a lot more. Sure, I’ve been using VMware’s products and services since about 2010, but the only real ‘engagement’ I’ve done in the community was attend the occasional VMUG or UserCon.
Continue reading “My Upcoming Central PA VMUG Presentation”
I recently had a request come through to see if there was a way to quickly find any/all virtual machines with Independent Disks attached. In this particular scenario, I’ll be looking for these types of VMs within a specific datacenter object. However, this script could easily be changed to scan an entire vCenter object, if needed. This script will look for VMs with both independent persistent as well as independent non-persistent disks.
Like some of my other scripts, this one also utilizes the try/catch when first connecting to a vCenter Server. For instance, if you attempt to connect to a vCenter and enter the wrong credentials or wrong server name/IP, it will stop the script and state that it “Could not connect to the vCenter Server <name>. In addition, I also have some logic built in to track the progress of the scan, as well as the option to export the results to CSV if preferred.
Continue reading “PowerCLI: Find VMs with Any Independent Disks”
A few months ago, I wrote two blog posts about how to find all UEFI- or BIOS-enabled virtual machines at the data center level within a vCenter Server. But what if you just want to quickly look up the boot firmware setting of a specific VM or even just a few of them?
I wrote this script as a way to quickly look up a small number of VMs to see if they might be good candidates for enabling Secure Boot or not. If you recall from those two posts, in order to enable Secure Boot, a VM needs to have virtual hardware version 13 or higher (meaning vSphere 6.5 or higher), and the VM boot firmware needs to be set to EFI.
Continue reading “PowerCLI: Quickly Look Up VM’s Boot Firmware Setting”
This script is an idea that spun off of my previous post, PowerCLI: Find UEFI-Enabled VMs. If you’re preparing to enable Secure Boot in a VMware environment, it may be helpful to identify the VMs that cannot be upgraded. As you might recall, enabling secure boot requires the following:
- VMware vSphere 6.5 or higher
- Virtual hardware version 13 or higher
- VMs need to be configured with EFI boot firmware
Continue reading “PowerCLI: Find BIOS-Enabled VMs”
With all the news regarding the Spectre and Meltdown CPU vulnerabilities over the past several months, there’s been a greater focus to get VMware virtual machines to virtual hardware version 9 or higher, as noted by Andrea Mauro’s post regarding these vulnerabilities. In addition to that, several companies and organizations may be looking to enable Secure Boot, a feature first introduced with vSphere 6.5. However, in order to enable secure boot, the virtual machine needs to be configured with both EFI boot firmware AND be on virtual hardware version 13 or higher.
Continue reading “PowerCLI: Find UEFI-Enabled VMs”
Earlier this week, someone on our team received a request to change a VMware virtual machine’s NIC from e1000 to VMXNET3. While the change was a bit manual in nature due to the Guest OS configuration changes, it got us thinking… How many other VM’s might still have e1000 NIC adapters? So, I started working on a script to find out. Continue reading “Finding NICs That Aren’t VMXNET3”
A quick follow-up to my experience presenting at the recent Western PA VMUG.
Hello again, everyone! First of all, I just want to take this opportunity to extend a HUGE “Thank You” to everyone who was able to come out and attend the recent Western PA VMUG! The day was packed full of information, as we got to hear a lot of great presentations about running VMware on AWS, AppDefense, vSphere APIs, and what’s new with PowerCLI. What I like most about these kinds of events is the ability to share, learn, network, meet new users, and catch up with those whom I already know.
As several folks already know, this was my very first time presenting at a VMware User Group meeting. Sure, I was a little nervous at first, but once I got up to present, things just seemed to flow. For me, it was reassuring to know that many in the audience were VMware customers who may have been in my shoes at one time, or perhaps still are. You never know. Although my presentation was mostly focused on some recent PowerCLI scripts I had developed to automate and simplify repetitive tasks, I also talked about my personal journey from avoiding scripting to actually doing it. And in my presentation, rather than just showing lines of code on a screen and explaining what the script does, I highlighted the workflow and thought process behind why I scripted it the way I did. Continue reading “Western PA VMUG Follow-Up”
So, as you can probably tell from my past couple of posts, I’ve been spending a bit of time working with PowerCLI to script and automate several tasks for managing VMware environments. My most recent script combines four tasks I seem to do often when performing cluster-wide maintenance; Enabling and Disabling both SSH and Lockdown Mode. This was actually one of the scripts I discussed at the recent Western PA VMUG meeting held on October 20, 2017.
In this script, like many of my other scripts, it asks the user to enter the vCenter server to connect to, as well as the cluster to work with. Then, the user is presented with five options:
- Enable SSH
- Disable Lockdown Mode
- Disable SSH
- Enable Lockdown Mode
Continue reading “PowerCLI: Enable/Disable SSH and Lockdown Mode”
I recently built out a new VMware cluster, and in doing so, needed to configure the NTP servers for each host. While this can certainly be done manually, it’s very repetitive and opens up the possibility of missing or misconfigured setting. Fortunately, there’s a way to automate that using PowerCLI!
Now, the way I wrote this script makes it a bit more interactive for the person running it. Typically, you could just define the NTP servers you want to remove, the ones to want to add, and let it run. With this script, it asks the user several questions along the way. Questions like, “What vCenter do you want to connect to?”, “What cluster do you want to scan?”, “Do you want to remove all existing NTP servers? [Y] / [N]”, and so on. There’s also validation included on the responses to the Y/N questions. And at the very end of the script, it checks the NTP services on each host in the cluster. If the NTP service is already running, it will restart the service. If it’s not running, it will start the service. All automatically. Continue reading “PowerCLI: Add/Remove NTP Servers in a VMware Cluster”