Checking you are up to date with PowerCLI

Now that PowerCLI is a module and in the PowerShell Gallery there have been a lot of releases and bug fixes, you would be forgiven for not having the latest version installed or even knowing what the latest version is.

With this in mind and with the latest 6.5.3 version triggering this in my mind, I created a function that checks your installed PowerCLI version against the one thats in the PowerShell Gallery online and lets you know if there is a new version.

Now of course this can be run manually and it will return the results letting you know which modules are out of date:

And once completed of course its easy to update PowerCLI to the latest version:

Even better why not add it to your profile. It does take a couple of seconds to run so maybe you will want to run it on a certain day past a certain time in your profile so it doesn’t slow down every launch of PowerShell you have, here is an example of what I have in my profile where I check every Wednesday after 2PM.

if ( ((Get-Date).tostring('%H') -ge "14" ) -and ( (Get-Date).DayofWeek -eq "Wednesday" ) ) {
        Check-PowerCLIUpdate
}

Check-PowerCLIUpdate Script

Here is the function that allows you to check for updates:

Function Check-PowerCLIUpdate {
    #Based on great module by Jeff Hicks here: http://jdhitsolutions.com/blog/powershell/5441/check-for-module-updates/
    [cmdletbinding()]
    Param()

    # Getting installed modules
    $modules = Get-Module -ListAvailable VMware* | Sort Version -Descending | Select-object -Unique

    #Filter to modules from the PSGallery
    $gallery = $modules.where({$_.repositorysourcelocation})

    # Comparing to online versions
    $AllUpdatedModules = @()
    foreach ($module in $gallery) {

         #find the current version in the gallery
         Try {
            $online = Find-Module -Name $module.name -Repository PSGallery -ErrorAction Stop
         }
         Catch {
            Write-Warning "Module $($module.name) was not found in the PSGallery and therefore not checked for an update"
         }

         #compare versions
         if ($online.version -gt $module.version) {
            $AllUpdatedModules += new-object PSObject -Property @{
                Name = $module.name
                InstalledVersion = $module.version
                OnlineVersion = $online.version
                Update = $True
                Path = $module.modulebase
             } 
         }
    }
    $AllUpdatedModules | Format-Table
    #Check completed

}

Virtual Machines meet Virtual Reality at VMworld US 2017

Normally when I create blogs and use the word “virtual” it of course refers to the awesome virtualization technology invented by VMware, this post however is a little different but still just as awesome!

The virtual word that I speak of in this post refers not just to virtual machines but also to virtual reality.  Having purchased a HTC Vive earlier this year and being totally inthralled by virtual reality (VR), I started to wonder what an enterprise world would look like if we all had VR headsets, how would we control todays applications in a VR world?

I don’t want to give away too much information just now as the excitement will be at VMworld and on stage, lets just say that managing your virtual infrastructure has never been so much fun, here is a teaser for now:

Want to win a HTC Vive and Alienware laptop?

This year at VMworld I will be presenting an awesome demo on stage with the following members of the VMware executive leadership team and VPs:

  • Raghu RaghuramChief Operating Officer – Products & Cloud Services
  • Mark LohmeyerVP Products for Cloud Platform Business Unit
  • Guido AppenzellerCTO Cloud & Networking

During this session we will be showing some cool integrations with Virtual Reality and VMware products.

As part of this session we will also be giving away a fully spec’d Dell Alienware laptop and a full HTC Vive headset and accessories.

Believe me, this is an awesome piece of equipment that will blow your mind!

To enter all you need to do is attend the following session, watch the demo and wait for the chance to win this amazing prize!

Session: Simplifying and Accelerating Your Multi-Cloud Strategy [IPC7001KU]

Add it to your session list here: https://my.vmworld.com/scripts/catalog/uscatalog.jsp?search=[IPC7001KU]&showEnrolled=false

Im looking forward to blowing some minds in this session!

 

Using the Runecast API with Postman

In my previous post I had worked with a version of Runecast and provided an initial look at the awesome app that helps keep your vSphere environment running at peak operational configuration.

As part of my feedback I suggested they start looking at a REST API, as it turns out the smart guys at Runecast were already way ahead of me and on June 13th released a new version with a great REST API and API Explorer to work with it, within a couple of clicks I updated my Runecast deployment to the latest version (super easy) and it gave me the latest and greatest features to work with including the API which can be found under the settings page and API Access token and then clicking the “Runecast API” link at the top, this brings up a swagger based API Explorer as seen below:

runecast-api-explorer

You can use the API live here or through any other REST based client, personally I like to try postman and start to understand the API a little more by creating a collection, this is exactly what I did and have made available via a github repo for you to download, use against your environment and also contribute back to with more samples in the collection.

Getting started with the Runecast Postman collection

Getting started couldn’t be easier just follow the below steps to use the collection against your Runecast server:

  1. Ensure you have Runecast 1.5.4.0 or above as this has the API
  2. Download and install Postman if you don’t have it already from https://www.getpostman.com/
  3. Download or clone my Runecast Postman Collection from my github repo from here
  4. You should now have 2 files from that repo, the first is the collection of REST calls and the second is an environment, the environment is used to specify 2 key pieces of information so we don’t have to keep retying these and also makes the collection portable.
  5. Open postman and click the import button at the top left, import the two files from the github repo and close the import button.
  6. You will now see the collection in the left hand pane and the environment will be available for you to adjust on the right hand side as seen below:

colelction

7. Next you will need to edit the environment and change the information to match your setup, firstly change the IP to the hostname or IP of your Runecast server.

8. Secondly change the APIKey to an APIKey that you have generated from the Runecast app, to do this go to Settings -> API Access tokens and select “Generate API access token“. Provide a description so you know what it is used for and once you click on “Generate“, your access token will be ready. Make sure to copy it, as you’ll not be able to see the same token again and we will need it in Postman. Paste the APIKey into the postman environment replacing the one in there at the moment and close the environment.

9. If all was done correctly above you should now be able to click on the collections and use the SEND button to call the API and see the results, note that some of these APIs require an ID which you will need to customize in the URL in postman as at the moment it has my IDs for things like my VC.

An example of me using postman to call the Runecast API is below:

Runecast-Postman-Usage

Conclusion

Using the Runecast API either by the API Explorer built into the app or via a standard REST based tool from the internet is super easy to do and allows integration and access to the wealth of details in the Runecast App, I hope the guys from Runecast extend this API to include configuration items in the future to allow a zero touch deployment of the app for automated rollouts but this is a great start.

Stay tuned for my next post where I will show you how we can easily integrate this with PowerCLI and get interesting information using a combination of PowerShell functions I have written and PowerCLI.

Ensuring peak configuration for vSphere with Runecast

Back in the day when I could spend time working on vCheck (I miss those days!) I always wished there was a programmatic way to look at the data in the VMware KB articles and be able to mine the information for potential issues or be aware of enhancements to the configuration I had made with my specific version of vCenter or other VMware products.

A few weeks back, whilst at the Melbourne and Syndey VMUGs in Australia I was introduced to a pretty awesome company and product that sparked my interest.. Runecast (https://www.runecast.biz/)

Recently I managed to find time to install this in my home lab and get started, I have to say, I was impressed.

What is Runecast?

Runecast is a virtual appliance which checks your environment, vCenter, ESXi servers and VMs to ensure they are running at peak performance with no known configuration issues or security issues.

The appliance is updated from the internet or can also be updated via a ISO image attached to the virtual appliance for environments without internet access.  It is updated with information which has been mined from the VMware KB articles and is used to proactively check log and configuration for issues in the virtual environment.

Additionally the information from the security hardening guide or what is now known as the vSphere Security Configuration Guide is also added to the virtual appliance to ensure security configuration is also taken into consideration. Continue reading

Is your PowerShell Core up to date?

I have been using PowerShell Core for a while now, its great not to have to spin up a windows VM every time I want to work with PowerShell on Mac!

Let’s face it though, not everything is there at the moment, so every time there is an update I want to know.  The Microsoft team are doing a great job of updating PowerShell Core and it seems like every time I go check there is a new version which fixes bug or introduces new cmdlets.

This does however mean I need to constantly go check the releases page or keep an eye on twitter to see when new releases come out.. until now!

The following function is a 5 minute function I wrote to keep on top of the updates, I have placed it in my PowerShell profile and now every time I launch PowerShell from my mac it checks and tells me if there is a new version as below:

Code

Just use the following code and paste it into the file located at $profile and every time you launch PowerShell it will go check for you!

Function Get-PowerShellRelease {
    #Using this to get rid of the nasty output Invoke-WebRequest gives you in PowerShell on the Mac
    $progress = $ProgressPreference
    $ProgressPreference = "SilentlyContinue"
    $JSON = Invoke-WebRequest "https://api.github.com/repos/powershell/powershell/releases/latest"| ConvertFrom-Json
    If ($psversiontable.GitCommitId) {
        If ($JSON.tag_name -ne $psversiontable.GitCommitId) {
            Write-Output "New version of PowerShell available!"
            $JSON.body
        } Else {
            "PowerShell is currently up to date!"
        }
    }
    $ProgressPreference = $progress
}

Get-PowerShellRelease

Retrieving NVMe details through PowerCLI

Recently I was contacted and asked if there was a way to retrieve information about the NVMe Drives in an ESXi host, this information is easily accessible via ESXCLI using the “nvme” namespaces.

Through PowerCLI this can be easily called and then each feature can be called under this namespace to give you detailed information on the NVMe devices in your ESXi host.  The reason they wanted to do this was to first check the firmware on all the NVMe devices in a cluster to see if they are at the latest revision.  Another reason they wanted this script was in case one of the NVMe devices was behaving differently than the others it would be an easy way to compare the devices.

You can see an example of the script running below:

Continue reading

Automating the VSAN HCL with PowerCLI

Recently I was contacted by a customer who needed to be able to update their VSAN Hardware Compatibility List in the VSAN Health Check but was unable to do so via the GUI as their vCenter servers did not have internet access.

This is a common setup as a lot of customers clearly do not want their Server infrastructure having a direct connection to the internet due to strict security requirements. The problem is when the vCenter server needs to update the VSAN HCL database file it requires a connection to the internet to do this. Whats more, this specific customer had several VCs and was getting quite frustrated with the warning that the HCL database had not been updated. Rather than turning this feature off the customer was looking for a way to update the HCL from a computer that had internet access – his desktop.

New in PowerCLI 6.5 (backwards compatible to previous versions) is a cmdlet that will help us achieve this… Update-VSANHCLDatabase, as you can see from the below image this can be run either grabbing the database information directly from the internet or if you add the “FilePath” parameter you can load the database locally.

Continue reading

Getting started with PowerCLI 6.5 and Horizon View

One of the recent enhancement released in PowerCLI 6.5 R1 was the addition of a new Horizon View Module which allows you to manage Horizon View from a remote connection, this is a huge enhancement from the previous PowerShell implementation which fell short by many means.

With the new Horizon View Module you will be able to access 100% of the public API meaning if its available as a feature in the UI then the likelihood is that you will be able to automate it and being able to use these from a scripting host with all the other PowerCLI features, your own workstation or a jump box makes this very convenient.

What do I need?

Lets get started…

image

Get-Module –ListAvailable VMware*Horizon* | Import-Module

Get-Command –Module Vmware.VimAutomation.HorizonView

 

Once you have installed PowerCLI 6.5 R1 and launched it you will see that if we import the module and list the commands all we have is 2 cmdlets to work with, well that isn’t much use is it?! or is it?
Continue reading

Automating the build of your vSphere 6.5 home lab

This year at VMworld SFO and BCN I was involved in organizing a couple of great hackathons with the @VMwareCode guys and William Lam, these were highly successful and I have to say the highlight of both my VMworlds.  The teams were great, the end projects were fantastic and most of all, everyone that attended told me they learned something, this if you ask me was the main objective for the hackathon.

If you attended I do want to extend a huge thanks for joining in, having fun and learning with us.

credc8rusaa8un0

To put the hacakthon together we needed to build up some environments for people to use, William came up with the idea of using Intel NUCs as these were easily transportable and packed a punch for their size, the equipment we purchased is listed below:

Quantity: 2 Crucial 16GB Single DDR4 2133 MT/s (PC4-17000) SODIMM 260-Pin Memory – CT16G4SFD8213
Quantity: 1 Intel NUC Kit NUC6i3SYH BOXNUC6I3SYH Silver/Black
Quantity: 1 Samsung 850 EVO 500GB 2.5-Inch SATA III Internal SSD (MZ-75E500B/AM) (For Capacity)
Quantity: 1 Samsung SM951 128 GB Internal Solid State Drive MZHPV128HDGM-00000 (For Performance)

For the hackathon we needed to build a lot of these units, whilst we did some parts of it manually William and I recently took the time to complete the automated deployment of these units, in fact the script is not specific to these units, it will work on any ESXi host with 2 disks, one for performance and 1 for capacity.  Of course you can also adjust the script to use more disks if you have them!

Once you have ESXi on a USB insert it into the machine and configure it to boot from the USB, after the ESXi machine is on the network you can alter the configuration settings in the start of the script and run the script in the Deployment Script section of this blog to automate the following:

  • Configure VSAN in a single node configuration (Unsupported)
    • Use the smaller SSD for performance
    • Use the larger SSD for Capacity
  • Configure NTP on the ESXi Host
  • Enable SSH on the ESXi Host for debugging
  • Configure the Syslog settings on the ESXi Host
  • Deploy the VCSA on the ESXi Host
  • Enable VSAN Traffic on the Management Network
  • Create a Datacenter
  • Create a Cluster
  • Create a subscribed content library for William Lams Nested ESXi Library
  • Enable Autostart so the VCSA VM starts when the ESXi machine powers on
  • Enable SSH on the VCSA Server

Continue reading