Skip to content

That... Could Be A Problem... Posts

Finding a VM’s Port-ID with PowerCLI

A question was recently brought up over finding a VM’s Port-ID with PowerCLI.

Right off the bat, I assumed the ask was for the distributed switch port. That wasn’t the case though. In this situation, the ask was to identify the Port-ID that was being displayed in ESXTOP via the Network view.

Example:
ESXTOP Network View Example

The Port-ID that’s being displayed is local to the host. That information isn’t available through the VM object, at least as far as I could find. In order to get the Port-ID through PowerCLI, we have to get a little crafty. This is going to require some ESXCLI usage.

Since we’re dealing with networking, we can automatically jump to the ESXCLI Network documentation on VMware Code. Luckily, there’s really only two commands that deal with VMs and we’re going to need both of them:

  • network vm list
  • network vm port list

We’ll use the network vm list command to obtain the VM’s World-ID and then use that as an input to the network vm port list command to receive back the local Port-ID for the VM!

Since the goal was to do this in PowerCLI, I created a script and added it to the PowerCLI Community Repo. The script is titled: Get-VMNetworkPortId.ps1

It can be used in a couple different ways, so use it however makes sense to you.

Example Usage:
Get-VMNetworkPortId Usage

After feeding in a VM by pipeline, making use of the VM parameter, and even passing multiple VMs to the script, we can see how the Port-ID does in fact match up with what’s displayed in the ESXTOP example from above.

The script is available on GitHub and looks like the following:

Learn Log Insight’s REST API with Postman!

Getting started with a new API is always… interesting. Here lately, I have found myself getting a lot better acquainted with Log Insight. If you’ve never heard of it, this is a log management solution from VMware.

Anyways, when I first start using an API I like to read through the docs and try some basic calls. Log Insight’s API documentation is pretty solid. However, when it turned time to start actually making some calls, I then had a wealth of tools at my disposal to make calls. This is a good problem to have!

I’m still new to this API, so I’m looking for the path of least resistance. Enter the Postman, a free REST Client. My favorite part of Postman is the ability to use Collections. These Postman Collections are literal collections of API calls that can then be exported/imported and shared.

I created a Log Insight collection and have shared it on GitHub: Log Insight Postman Collection

Prepping the Client

Prerequisite: Have the Postman desktop client installed. (I haven’t tested this in the Chrome app)

We can start using this collection by heading out to my GitHub Repository and downloading it in your preferred method. For this example, I’ll be downloading it as a ZIP file.

Download GitHub Repo

Extract the ZIP to a location of your choosing.

Open Postman, click the “Import” box (alternatively, File -> Import)

Import Postman Collection to Client

Select the “Log Insight.postman_collection.json” file

Select appropriate JSON file

We will see a new folder titled “Log Insight” which contains 49 requests:

Sample Collection View

Preparing Environmental Variables

Another great reason to use Postman is the ability to use environmental variables. I highly recommend using these as it will greatly simplify the experience.

We will need to create the following variables:

  • li – this will be the Log Insight node we’ll be making calls against
  • auth – this is the authorization string that is referenced in each call’s header

To create these variables, we’ll need to go to the gear icon towards the top right corner and select “Manage Environments”

Manage Environments Option

On the “Manage Environments” section, click “Add”

Manage Environments Layout

We can then give the environment a name and start filling in those variables I listed above (since we do not yet have a Session ID, the auth variable will be left blank), then click “Add”

Log Insight Demo Environment Setup

We can now close out of the “Manage Environments” section by clicking on the “X”

We now want to configure Postman to reference these variables. To do this, we will select the “Environment” dropdown box and select the environment we just created.

Choosing to use the new Log Insight Demo Environment

Authenticating

The first call we’ll want to perform is to authenticate to the Log Insight node and receive our Session ID.

To do this select the “Sessions” folder, then click on the “Login” request.

Exploring the Session Login Request

We’ll now select the “Body” tab. Here we’ll see a preformed body in JSON format. Modify the values to match that of your environment.

Exploring a sample body

We can now click “Send” to actually perform the API call

Example response

If all goes well, you’ll receive a status of “200 OK” and a result like the above.

Now that we have our session ID, we’ll need to fill in our “auth” variable so that we can start easily using the Log Insight API.

Copy the sessionId value within the quotations and head back to the “Manage Environment” section.

Click on the Environment we created earlier, then click into the “Value” section for the “auth” variable:

Update Environmental Variables

Referencing the Log Insight API documentation on authentication, for the Authorization variable we will want to type “Bearer” followed by a space and then the sessionId value

Example Auth variable for the Environment

Click “Update” then close out of the “Manage Environment” section by clicking on the “X” in the top right corner

Making Log Insight API Calls

At this point we have our Postman Collection imported, our session is authenticated, and our variables are set! We can now start making calls to the Log Insight node.

Example: Finding out what authentication providers are available

Select the “Auth-Providers” folder, click “List”, then click “Send”

Auth Providers Sample Response

Example: Obtaining a list of Events

Select the “Events” folder, click “List”, then click “Send”

Sample Events List Response

One Last Thing

There’s a couple areas where appears to be a variable, but it’s not one that we’ve configured.

Example: Within the “Licenses” folder there’s a “Remove” request.

Clicking on the request gives us the following for the request URL:

Exploring License Removal Request

Noting the “{license}” portion of the URL, this section is supposed to be overwritten with an actual value. If we reference the above screenshot, we can see that there is an “Example” we can refer to (top right corner, beneath the “Manage Environments” icon).

Clicking on that example button will take us to an example of what the call will look like along with a sample response.

Exploring License Removal Request Example

Wrap-Up

Getting started using an API can be a lot of things. This Postman Collection should be a great resource to start learning and using the Log Insight API. I know I learned a lot by creating and using it. If there’s any suggestions or additional examples you’d like to see, please submit an Issue against the repo with those notes. Better yet, contribute back by forking the repo and creating a pull request with those updates!

Upgrading the Home Lab

Home labs are always a hotly contested topic. Do you need one, do you not? Can you host it or should it be physical? Can you make do with hand-me down gear or should you buy new? Will it stay powered on or only powered on for lab work? And this goes on and on until you’re absolutely tired of thinking about it.

In my case, I’ve had a home lab for around 4 or 5 years now. I went the new physical route. I found a Dell tower (T110) with a Xeon processor and 16GB RAM for pretty cheap and made it work. It was good enough for multiple VCAPs, a bunch of blog posts, and enough learning to earn a couple new social designations.

However, slowly over the years, my home lab was being shutdown less and less. There were things now running in it which had an uptime requirement (mostly self-imposed) and that 16GB of RAM was almost always over-subscribed.

This all means that it was time for a home lab upgrade! There were lots of characteristics to take into account such as the lab’s footprint, cooling, power, connectivity, noise, and so forth. After a couple months battling back and forth between the new Intel NUCs and SuperMicro Xeon-D systems, I ended up going the SuperMicro route. I also decided to go with the rackmount option. The rackmount cases have slightly less depth than most closet shelves and plenty of space to adding in a bunch of extra drives or PCIe devices.

Next was choosing the board. This offers its own complexity because the X10SDV boards have gained popularity over the years and there’s a bunch of different combinations. I ended up landing on the board with the Intel Xeon D-1528 processor. It has 6 cores (12 threads), goes up to 128GB RAM, and only requires 35W of power. I also skipped the sticker shock of going straight to 128GB right away and went with 64GB.

The Build

Primary Components:
SuperMicro CSE-505-203B Case – LINK
Intel X10SDV-6C+-TLN4f Motherboard – LINK
Samsung 32GB DDR4 RAM x 2 – LINK

Accessories:
I/O Shield – LINK
40x28mm fan x 2 – LINK
Fan Hold x 2 – LINK
Hard Drive Retention Bracket – LINK

As the links indicate, I used WiredZone for the purchase. They’re an authorized reseller and had everything in stock. I would definitely order from them again.

Assembly

Couple days later the parts started arriving and it was time for assembly! This was a little more frustrating than I anticipated. Pain points were the power connection and the fans.

The power problem was due to the case PSU including a 20-pin connection while the motherboard had a 24-pin power connection. I had read a couple places that these boards could be powered multiple ways, one through the 24-pin connection and the other through a 4-pin connection. However, they should NOT be used at the same time. After some discussion on the OpenHomeLab slack group with Mark Brookfield, we got it sorted how the power should be on pins 1 through 10 and 13 through 22. Big thanks to the OpenHomeLab folks and Mark especially. I was also able to confirm this configuration through WiredZone, whom responded back in less than 24 hours.

PSU Connection
Motherboard Power Connected using 20 of 24 Pins

The other issue was with the fans. I ordered some fans since the server would be sitting on a shelf somewhere in my house. Basically, the more fans to move the hot air out the better. The fun with the fans was because there’s not really any instructions on what to do with them or the fan holders. The fan holders did end up connecting together and then they basically sit on top of these pins. From that point, the fans literally just sit in the holders and are connected to the fan accessory ports on the motherboard. The case top is what helps hold everything together. Certainly not what I expected, but it’s moderately better than zip tying the fans to the case.

SuperMicro Dual Fan Holder Assembled
SuperMicro Dual Fan Holder Assembled

Fan Holder Pins Inserted
Fan Holder Pins Inserted in the Case

Holder and Fans Installed
Fans and Holder Installed in the Case

Everything else was extremely straight forward. Only other wish, the case could use some extra room for better cable management. You’ll see why in the assembly images below.

505-203B Case
SuperMicro 505-203B Case

Case and Motherboard Installed
SuperMicro 505-203B Case and Intel X10SDV-6C+-TLN4f Motherboard

IO Shield Installed
IO Shield Installed

Install Completed
Installation Completed

In Action

It’s all cabled up and I can finally hit the power button and watch it spring to life, which it did with no fuss.

First thing I did afterwards was configure the BIOS settings as per Paul Braren‘s advice over at TinkerTry: Recommended BIOS Settings for Supermicro SuperServer SYS-5028D-TN4T

Next up, install ESXi to an attached USB thumb drive. I did this by way of the motherboard’s KVM and it was quite easy, just like it would be via an HP iLO or Dell DRAC.

Lastly, install the VIB to make the 10GbE ports work properly. Paul has a great write-up on that as well over at TinkerTry: How to download and install the Intel Xeon D 10GbE X552/X557 driver/VIB for VMware ESXi 6.x

I had the system running for 90 days straight before I shut it down to start the upgrade to vSphere 6.5. No hiccups or any issues whatsoever. I’ve been extremely happy with the purchase, almost to the point of wondering why I hadn’t done it sooner.

Server Running Status via ESXi
Home Lab Server running for 88 days!

Server Installed
Current Living Quarters for my Home Lab

If you have any questions as you’re reading this, feel free to use the comments or find me on Twitter. Also check out the OpenHomeLab site and their slack channel, and definitely browse through Paul Braren‘s blog TinkerTry. Paul has done an immense amount of research and countless hours of hands-on work with these SuperMicro motherboards.

Now to start thinking through the next home lab upgrade whether I should do vSAN or upgrade my Synology…

So You’re Thinking About Learning PowerShell…

This year has been a wild ride for me. Earlier this year, I offered to do a couple community sessions based on automation with PowerShell. Unbelievably, every session was accepted and, even more so, every session was well attended. It really seemed like the attendees took something away from the session regardless of their experience level.

More recently, I was allowed the chance to present a session at VMworld about some fundamentals of getting started with PowerShell and PowerCLI. The session, which was co-presented with fellow PowerShell enthusiast Chris Wahl, ended up having three separate sessions that week and the rooms were full for all three sessions. The response was incredible. We even earned one of the Top Ten Sessions of the day that week!

I’m not the only one seeing this trend, there’s been a couple other community members also seeing the popularity of the topic. It’s exciting to have all these people new to PowerShell and see them have that “lightbulb moment” where all the possibilities click.

Getting Started

Getting back to the purpose of this post, why and how should you get started with PowerShell. I’ve collected a couple resources to help people do just that. One side note, you’ll notice I talk about PowerCLI a bit. Personally, I learned PowerShell in order to use PowerCLI. It was really the gateway into the much larger PowerShell ecosystem.

At the last UK Northwest VMUG meeting, David Hocking presented a community session on PowerShell for Beginners. Unfortunately, I couldn’t be there but he did post the deck on Twitter and I’ve embedded a link to below. It covers some of the reasons why he started with PowerShell, what his background was, and some great ways to get started. If you go to the last slide, there’s a link to download his example scripts and checkout some of the demo videos.

I mentioned the VMworld session earlier, it was posted to YouTube so you can access that directly. Chris and I will walk you through some of the lingo involved in getting started, then help get you started on writing code and some logic statements.

If you’re ready to get some hands-on time without impacting your own environment, there’s resources such as the VMware Hands-On Labs. It’s worth mentioning that there is an enrollment process, but it’s completely free. Couple lab examples:

  • HOL-SDC-1607 From Beginner to Advanced Features with PowerCLI – This lab will provide you with an environment and a lab guide to walk you through performing some tasks with PowerShell and PowerCLI.
  • HOL-1710-USE-4 – vSphere with Operations Management: Advanced Use Cases – This lab, again, provides you with an environment but the lab guide is targeted to be using the PowerCLI module with vRealize Operations Manager (vR Ops). As a beginner I wouldn’t advise following the lab guide, but instead using the lab to explore some of the cmdlets in an updated environment.
  • HOL-1721-SDC-6 – Introduction to VMware PowerCLI – If you happen to be at VMworld Europe, this is a huge recommendation. When this lab is posted to the public Hands-On Lab page, this will be my recommended go-to lab. The lab walks users through some of the basic configuration tasks a vSphere Administrator would do and how to automate those tasks. The lab captain, Vinith Menon, did a fantastic job on it.

Other Resources

Some other resources out there that have helped me:

  • Book: Learn Windows PowerShell in a Month of Lunches – Great resource that helps readers step through the fundamentals. Even after finishing it, you keep it as a reference. I can’t tell you how many times I’ve gone back to it as a refresher to something I forgot.
  • Book: Learning PowerCLI – Another great book, this one more focused on the vSphere Administrator. There’s a good overview of PowerShell in general and then it dives right into automating normal vSphere tasks.

If you’re a more visual learner, Pluralsight have a giant section of PowerShell and PowerCLI based videos. Here’s just a couple of them that helped me get started:

Lastly, and I can’t stress this enough, get involved in the community. Connect and network with people that you can bounce ideas off of and learn from. There’s a wide variety of ways to do so. User groups are a fantastic way to get started. There are PowerShell User Groups, VMware User Groups, and most any other technology based user group as well. If there isn’t one local to you, join a slack team. There’s a PowerShell Slack team, VMware Code Slack team, and so forth.

If you’ve found something else to be a great resource to help learn PowerShell, or PowerCLI, please let me know in the comments.

EUC Day 2016: PowerCLI for View

The Minneapolis VMUG had a terrific idea to put together a specialized event based around End User Computing (EUC) and I was lucky enough to be asked to come and present something around automation.

That brings me to the session I chose, which is an introduction to PowerCLI for View. Horizon View and automation (Powershell, specifically) aren’t something that go together all that well at this point in time. PowerCLI for View is a great utility, don’t think I’m taking anything away from it nor bashing it, but it does take some understanding to kinda set the groundwork before you dive-in head first. This session is my attempt to help set that groundwork.

Thanks again to Matt Heldstab and the rest of the MN VMUG team for having me out, the event was awesome. I also want to call out the rest of the sessions from that day, which can be found on YouTube: https://www.youtube.com/channel/UCMHCjDBAx2NhBlTRi2ud90A/videos?shelf_id=0&view=0&sort=dd

PoSh – vCenter License Handling

It’s that time of year again for vExperts… Time to replace the NFR licenses the vExpert program has graciously supplied us.

Was given a gentle reminder of this the other day while preparing for a vBrownbag presentation:
Expiring Licenses

I’ve been on a big Powershell module making binge lately and noticed there really isn’t much for handling vCenter’s licensing, so I created one and published it out on Github.

An overview of what’s currently included in the module:

Function Name Description
Get-VILicenses Gathers information on all VI licenses availabe in the vCenter Server
Get-VILicenses
Get-VILicenseInfo Gathers information on the supplied license key
Get-VILicenseInfo
Add-VILicense Adds the supplied license key to the vCenter Server license inventory
Add-VILicense
Remove-VILicense Removes the supplied license key from the vCenter Server license inventory
Remove-VILicense
Set-VILicense Sets the supplied license key to the desired VI Object
Set-VILicense
Get-VILicense Gathers information on the supplied license key from the VIObject
Get-VILicense

A general walk-through of what’s occurring within each function is Powershell interfacing with the License Manager object via VMware’s SDK.

Requirements:
PowerCLI modules and/or PSSnapins
Active connection to a vCenter Server

An automated way of downloading the files into a dedicated directory and importing the module into the current session:

Note: this was a script that worked in my environment. There is no warranty or support with this script, please use at your own risk.

Commitmas: Learning Git Revert

Commitmas time has come again!

For those of you that aren’t aware, Commitmas is a program which started last year (2014) with a goal of pushing people to learn how to use GitHub by way of 12 days of different challenges. This year has been expanded out to include the entire month for a full 30 days worth of challenges.

Last year I followed along and tried to push myself to learn how to better use GitHub as I was a very basic user. This year I’m making attempts to be much more involved and even picked up a challenge to present on. The challenge I selected was titled “Wait, I screwed something up and need to roll it back!” and is located at the following link: Commitmas 2015 – Challenge 10

The following session was recorded on December 10th and outlines the challenge and ways to complete it:

Additional Commitmas information and the rest of the challenges can be found on GitHub: https://github.com/commitmas/30-days-of-commitmas-2015

Nutanix CE Now Available on Ravello!

Two companies that have been doing some pretty cool things on their own have now joined up to offer something very awesome. As of November 17th, Ravello will now be offering a preconfigured Nutanix Blueprint for use with their HVX nested hypervisor offering.

Things to know:

  • The blueprint being offered is the Community Edition (CE) and has all the existing limitations therein. More information can be found on: Nutanix’s site
  • A Nutanix NEXT account will be required to use the appliance on Ravello. Sign up is quick and easy, my account took under 5 minutes to create and gain CE access. You can create a NEXT account on: Nutanix’s site
  • A Nutanix NEXT account requires a “business email”, ie. non-gmail/live/hotmail/etc
  • The appliance asks for 4 CPUs and 16GB RAM. In my account, it was estimated at roughly $1.13/hour to run out of Amazon’s cloud.
  • If you happen to be a vExpert with a Ravello account, you may have noticed there’s an 8GB/VM limit. With this release, that limit has been bumped to 16GB… on all VMs!

You may be asking “why is this a big deal?” at this point. Nutanix has offered their CE offering for a fair amount of time and the minimum requirements are pretty relaxed, right? While both are true, it’s never been this simple. You don’t need any hardware at all, just a Ravello & Nutanix NEXT account and 15 to 20 minutes and you have an operational single node cluster available whenever you need it for whatever reason you need it.

Let’s walk through getting started:
First, log in to your Ravello account and select the Ravello Repo in the top right-hand corner. There will then be a new window where searching for “Nutanix” will bring up the “Nutanix Community Edition” Blueprint which can be added to your Library by simply clicking “Add to Library”.
Ravello Repo

Once complete, head to the “Applications” area and select “Create Application”.
Give the new application a meaningful name, check mark the “From Blueprint” option, select the “Nutanix CE…” Blueprint, and select “Create”.
Create Nutanix Application

When the application creation completes, you’ll be brought to the “Canvas” page for that application. Let’s take a second to review the specs on the newly created VM:
Nutanix VM Specs

When reviewing the VM is complete, as I wouldn’t recommend changing anything at this point, click on the publish button to push the system out to the desired cloud and get it started.
Note: it’s configured to auto-start, so don’t walk away. It doesn’t take long at all to deploy and it just unnecessarily uses resources as you’re paying for it’s use or, as a vExpert only given a specific allotment.
Publish Nutanix Application

Once it’s deployed, how do you get to it? Click on the Nutanix VM again and off to the bottom right-hand side you’ll notice the status for the VM. Within that box, look in the “External access for” box for the NIC which lists in the “Ports” area “9440 (https)”. The DNS name and IP is where the PRISM management interface can be loaded. Example:
VM Status Information
Nutanix PRISM Interface

An item to note if you’re new to Ravello, the IPs persistent only while that Application is running. Once the Application is shutdown, the IPs are recycled quite quickly. However, the DNS names are persistent and are easily copied out of the VM Status area. I used the IP in these screenshots for simplicity and to hide the public name of my instance.

Logging in is simple, username and password are both “admin”. It will prompt for the user to then change the password. Once that’s complete, it will ask you to login via the user’s NEXT credentials. Once authenticated through, you’re all done! Here’s a peek at what it looked like for me:
Nutanix Web Console

Definitely want to say thanks to both Ravello and Nutanix for making this happen, and also another thanks for offering a special briefing and early access to the vExperts!

PowerCLI – Quick Stats Not Up To Date Error

Recently rebooted one of my vCenters and came across an error on my ESXi hosts stating “Quick stats on *vmhost* is not up-to-date”. A couple seconds worth of googling brought me to VMware KB2061008 which helped to resolve the issue.
Quick Stats Error Message

However, the KB only went through the GUI process of adding in the requisite parameters but there’s no fun in clicking through the GUI so I came up with a short script that’s applicable to vCenter 6.0 which can also accomplish performing the parameter creation/updates for the KB’s workaround.

Once you run the script, you’ll still need to restart the vCenter service on your VCSA or Windows server. If you happen to be in the web client:
Go to “Administration” then to the “Deployment” area to select “System Configuration”
Select “Services”, then select “VMware vCenter Server”
Select “Actions” followed by “Restart”

Once the service is back up and running the error will no longer be present.
vCenter Service Restart

Note: this was a script that worked in my environment. There is no warranty or support with this script, please use at your own risk.

PoSh – NSX Module Update

A new update has been published to the NSX Module which I previously published on GitHub: https://github.com/kmruddy/Powershell/tree/master/Modules/NSXModule

A reference to the first blog post I made concerning the module, including some screenshots of it actually in use: http://thatcouldbeaproblem.com/?p=823

The module has now grown to 31 of the following cmdlets:

Cmdlet Description
Get-NSXController Gathers NSX Controller details from NSX Manager
Get-NSXControllerUpgrade Gathers NSX Controller Upgrade details from NSX Manager
Get-NSXEdge Gathers NSX Edge Node details from NSX Manager
Get-NSXEdgeDefaultRoute Gathers NSX Edge Node default route details from NSX Manager
Get-NSXEdgeFeatures Gathers NSX Edge Feature details from all nodes within NSX Manager
Get-NSXEdgeFirewall Gathers NSX Edge Node firewall details from NSX Manager
Get-NSXEdgeInterfaces Gathers NSX Edge Node’s Interface details from NSX Manager
Get-NSXEdgeNATs Gathers NSX Edge Node NAT details from NSX Manager
Get-NSXEdgeRoutingOverview Gathers NSX Edge Routing Overview details from all nodes within NSX Manager
Get-NSXEdges Gathers NSX Edge Node details from NSX Manager
Get-NSXEdgeStaticRoute Gathers NSX Edge Node static route details from NSX Manager
Get-NSXEdgeUplinks Gathers NSX Edge Uplink details from all nodes within NSX Manager
Get-NSXIPPools Gathers NSX IP Pool details from NSX Manager
Get-NSXIPSets Gathers NSX IP Set details from NSX Manager
Get-NSXLogicalSwitches Gathers NSX Logical Switches and their details from NSX Manager
Get-NSXManager Gathers NSX Manager details
Get-NSXManagerComponents Gathers NSX Manager component details
Get-NSXManagerSSH Gathers NSX Manager SSH component details
Get-NSXScopes Gathers NSX Scopes and their details from NSX Manager
Get-NSXSSOConfig Gathers NSX SSO details from NSX Manager
New-NSXIPPool Creates an NSX IP Pool within NSX Manager
New-NSXIPSet Creates a new NSX IP Set within NSX Manager
New-NSXLogicalSwitch Gathers NSX Logical Switches and their details from NSX Manager
Remove-NSXEdge Deletes an NSX Edge Node from NSX Manager
Remove-NSXIPPool Removes an NSX IP Pool within NSX Manager
Remove-NSXIPSet Removes an NSX IP Set within NSX Manager
Remove-NSXLogicalSwitch Gathers NSX Logical Switches and their details from NSX Manager
Remove-NSXSSOConfig Removes NSX SSO config from NSX Manager
Restart-NSXManager Configures the NSX Manager for reboot
Set-NSXManagerSSH Configures NSX Manager SSH component
Update-NSXEdge Updates the NSX Edge via Update parameter

If you need an automated way of downloading the files into a dedicated directory and importing the module into the current session please see the following:

Note: this was a script that worked in my environment. There is no warranty or support with this script, please use at your own risk.