-
Basic VMware Cluster Capacity Check with PowerCLI
Posted on January 18th, 2012 7 commentsI recently needed to provide a high level capacity overview per VMware cluster looking at some metrics of interest that were being used as a guide to the capacity state of a cluster. Note: these are by no means definitive or the ones you should be using in your environment, but for these purposes they met the requirements. The metrics I looked at per cluster were the ratio of vCPUs to pCPUs, the amount of Effective, Allocated and average Active Memory and the amount of Free Diskspace.
A couple of things to note:
1.The section below on datastore freespace filters out the local datastore which contains the name of the host.
$VMHost = $Cluster | Get-VMHost | Select-Object -Last 1 $HostName = ($VMHost.name -split ".", 0, "simplematch")[0] $ClusterFreeDiskspaceGB = ($VMHost | Get-Datastore | Where-Object {$_.Name -notmatch $HostName} | Measure-Object -Property FreeSpaceGB -Sum).Sum2. I’ve recently changed the way I create custom objects to output reports with. For a long time I have used the cheat way of Select-Object , partly because of performance and partly because you can’t control the order of properties in New-Object. These are being addressed in PowerShell v3 (see here and here) so I thought it was about time to make the switch. This means for the time being that when working with the output you need to pipe it to Select-Object to control the order of the output, e.g.
Get-Cluster | Get-ClusterCapacityCheck | Select-Object Cluster,ClusterCPUCores,ClusterAllocatedvCPUs,ClustervCPUpCPURatio,ClusterEffectiveMemoryGB,
ClusterAllocatedMemoryGB,ClusterActiveMemoryPercentage,ClusterFreeDiskspaceGB
function Get-ClusterCapacityCheck { <# .SYNOPSIS Retrieves basic capacity info for VMware clusters .DESCRIPTION Retrieves basic capacity info for VMware clusters .PARAMETER ClusterName Name of the computer to test the services for .EXAMPLE PS C:\> Get-ClusterCapacityCheck -ClusterName Cluster01 .EXAMPLE PS C:\> Get-Cluster | Get-ClusterCapacityCheck .NOTES Author: Jonathan Medd Date: 18/01/2012 #> [CmdletBinding()] param( [Parameter(Position=0,Mandatory=$true,HelpMessage="Name of the cluster to test", ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$true)] [System.String] $ClusterName ) begin { $Finish = (Get-Date -Hour 0 -Minute 0 -Second 0) $Start = $Finish.AddDays(-1).AddSeconds(1) New-VIProperty -Name FreeSpaceGB -ObjectType Datastore -Value { param($ds) [Math]::Round($ds.FreeSpaceMb/1KB,0) } -Force } process { $Cluster = Get-Cluster $ClusterName $ClusterCPUCores = $Cluster.ExtensionData.Summary.NumCpuCores $ClusterEffectiveMemoryGB = [math]::round(($Cluster.ExtensionData.Summary.EffectiveMemory / 1KB),0) $ClusterVMs = $Cluster | Get-VM $ClusterAllocatedvCPUs = ($ClusterVMs | Measure-Object -Property NumCPu -Sum).Sum $ClusterAllocatedMemoryGB = [math]::round(($ClusterVMs | Measure-Object -Property MemoryMB -Sum).Sum / 1KB) $ClustervCPUpCPURatio = [math]::round($ClusterAllocatedvCPUs / $ClusterCPUCores,2) $ClusterActiveMemoryPercentage = [math]::round(($Cluster | Get-Stat -Stat mem.usage.average -Start $Start -Finish $Finish | Measure-Object -Property Value -Average).Average,0) $VMHost = $Cluster | Get-VMHost | Select-Object -Last 1 $ClusterFreeDiskspaceGB = ($VMHost | Get-Datastore | Where-Object {$_.Extensiondata.Summary.MultipleHostAccess -eq $True} | Measure-Object -Property FreeSpaceGB -Sum).Sum New-Object -TypeName PSObject -Property @{ Cluster = $Cluster.Name ClusterCPUCores = $ClusterCPUCores ClusterAllocatedvCPUs = $ClusterAllocatedvCPUs ClustervCPUpCPURatio = $ClustervCPUpCPURatio ClusterEffectiveMemoryGB = $ClusterEffectiveMemoryGB ClusterAllocatedMemoryGB = $ClusterAllocatedMemoryGB ClusterActiveMemoryPercentage = $ClusterActiveMemoryPercentage ClusterFreeDiskspaceGB = $ClusterFreeDiskspaceGB } } } -
Configuring HP EVA Recommended Settings for ESXi via PowerCLI
Posted on December 21st, 2011 2 commentsThe HP Enterprise Virtual Array Family with VMware vSphere 4.0 , 4.1 AND 5.0 Configuration Best Practises Guide, available here, contains many recommendations for ESXi configuration. There are a number of recommended settings in this document to enhance the storage performance, a subset of which I have picked as appropriate for the environment and then needed to configure them on all ESXi hosts.
They can be implemented via PowerCLI and the below script demonstrates how these different types of settings can be configured. The most interesting one for me was setting the default Path Selection Policy to VMW_PSP_RR. The guide recommends you use the following command from the ESXi console:
esxcli nmp satp setdefaultpsp -satp VMW_SATP_ALUA -psp VMW_PSP_RR
With the introduction of the Get-ESXCLI cmdlet we can now carry out the equivalent from PowerCLI. Get-EsxCLI requires a direct connection to the ESXi host rather than from vCenter, so all the settings in this script are configured via a direct connection to the ESXi host
Warning: Before carrying out any of these types of changes make sure you talk to your Storage Adminstrator to confirm what is appropriate for your own environment. Other array vendors offer different recommendations so be sure to check their documentation for similar settings.
<# .SYNOPSIS Implement HP Recommended Settings for EVA SAN .DESCRIPTION Implement HP Recommended Settings for EVA SAN .PARAMETER HostName Name of the ESXi host to configure the settings on .EXAMPLE PS C:\> ./Set-HPEVAESXiConfig.ps1 -Hostname ESX01 .EXAMPLE PS C:\> Get-Content ESXServers.txt | ./Set-HPEVAESXiConfig.ps1 .NOTES Author: Jonathan Medd Date: 21/12/2011 #> [CmdletBinding()] param( [Parameter(Position=0,Mandatory=$true,HelpMessage="Name of the ESXi host to configure the settings on", ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$True)] [Alias('IPAddress','Server','ComputerName')] [System.String] $HostName ) begin { Write-Host "Please enter credentials to connect to the ESXi hosts" -ForegroundColor:Yellow $Credential = Get-Credential $UserName = $Credential.GetNetworkCredential().UserName $Password = $Credential.GetNetworkCredential().Password } process { Connect-VIServer $Hostname -User $Username -Password $Password | Out-Null Write-Host "Setting Disk.DiskMaxIOSize Advanced Option" Set-VMHostAdvancedConfiguration -VMHost $Hostname -Name Disk.DiskMaxIOSize -Value 128 | Out-Null Write-Host "Changing any LUNs with MultipathPolicy set to MostRecentlyUsed to be RoundRobin instead" Get-ScsiLun -VmHost $Hostname -LunType "disk" | Where-Object {$_.MultipathPolicy –eq "MostRecentlyUsed"} | Set-ScsiLun -MultipathPolicy "RoundRobin" | Out-Null Write-Host "Setting the default PSP to be VMW_PSP_RR" $esxCli = Get-EsxCli –Server $Hostname $esxCli.nmp.satp.setdefaultpsp("VMW_PSP_RR", "VMW_SATP_ALUA") Write-Host "Disconnecting from Host" $DefaultVIServer | Disconnect-VIServer -Confirm:$false }esxi, HP, powercli, powershell, vmware esxi, HP, powercli, powershell, vmware -
UK VMUG Nov 2011 Review
Posted on December 14th, 2011 No commentsA few weeks ago I attended the first ever UK based VMUG at the National Motorcycle Museum in Birmingham. Put together by the same folks who arrange the London VMUG events, it was a great day out and obviously a lot of hard work had been put in by Jane, Alaric, Simon , Stuart and Martyn. I know they had put the best part of 6 months into arranging it, so a lot of effort. By staging the event in the Midlands and involving other VMUGs from the UK, including the North of England, Scotland and Ireland there were over 300 attendees.
I travelled up the night before and just about made it in time for a pre-show vCurry being held at the Museum. This gave a good chance to catch up with various tweeps, since I figured (and I think it panned out) that people wouldn’t hang around too long after the main event the next day, like they normally do at the London VUMG, with longer journeys home.
There were also more sponsors than the London events and with involvement from the Official VMUG organisation there was even a posh looking programme to accompany the day’s events. How things have come one since I attended my first London VMUG about 3 years ago!
The event centered around the main area below with the keynotes from the stage at the front and vendors around the outside. This was accompanied by breakout sessions in rooms off to the sides. The only downside of the day was the lack of WIFI or 3G access since we were a couple of floors down, but thanks to the distribution of some BT OpenZone cards it was possible to stay reasonably well connected.
I had volunteered to assist Alan Renouf with a PowerCLI lab he had put together, which took place at the back of the main room.
We turned this into a drop by area for questions about PowerCLI and PowerShell as well. While the lab proved pretty popular, the best part was taking people’s questions and showing them how PowerCLI and PowerShell might help them out in their jobs. It was quite surprising to find that there were many questions such as ‘What are they?’, ‘What can I do with them?’ and ‘How much do they cost?’ – and a lot assuming I was a VMware employee! A lot of these conversations spurned off into Alan sitting them down, demonstrating some coding and often writing a script for them to take away.
I managed to get away to a couple of the sessions and in particular enjoyed Julian Wood’s session on upgrading to vSphere 5, which was really well attended. One of the other most intriguing parts of the day was a mock VCDX panel organised by Simon Gallager. This was an opportunity for people to practise defending a vSphere design (with a lot of onlookers for extra pressure!). You’ll notice that Duncan Epping was helping with this so the volunteers were grilled, but also received excellent feedback. The PowerCLI drop by area was positioned right next to this while it was going on and I know a number of people found the experience really useful when I talked to them as they walked away from it.
I really enjoyed the day as a Community Booth Babe and now know how draining it is being on a stand all day (you can probably tell from my dishevelled look below!). The best thing for me was answering people’s PowerCLI and PowerShell questions, really kept me on my toes. The highlight being one guy who was driving into work every Saturday, carrying out a few tasks inside a VM, powering it off, taking a clone, powering it back on and then driving home – I showed him how he could schedule this with a script and get his Saturday back
Hopefully the team will arrange another UK centered VMUG next year after the success of this one. In the meantime, details have just been published of the next London VMUG on January 26th. I highly recommend you attend this.
To round things off I made my way home in very ecological style with a lift from an ex-colleague and and his awesome company vehicle
-
What’s New In PowerCLI 5.0 – Slides from UK PowerShell UserGroup
Posted on November 22nd, 2011 3 commentsAs promised, here are my slides from this evening’s UK PowerShell UserGroup – What’s New in PowerCLI 5.0.
What’s New in PowerCLI 5.0View more presentations from jonathanmeddsf
-
What’s New in PowerCLI 5.0 – UK PowerShell User Group 22nd November
Posted on November 18th, 2011 No commentsA quick post to let you know that I shall be presenting for an online meeting of the UK PowerShell User Group on the topic of ‘What’s New in PowerCLI 5.0′ at 21.00 GMT on Tuesday November 22nd.
Details on how to join in are available from Richard Siddaway’s website.
Hope you can join us.
-
PowerCLI Drop In Area at the UK National VMUG November 3rd
Posted on October 26th, 2011 No commentsThere are a lot of great reasons to sign up for the UK National VMUG on November 3rd 2011, full details are below.
One reason to highlight is that during the day, Alan Renouf and I will be staffing the PowerCLI Drop In Area. We’re currently finalising the details, but this will likely consist of pre-prepared PowerCLI lab content for you to work through and also an opportunity to ask PowerCLI or PowerShell questions. We’ll be there throughout the day so there should be plenty of time for us to help you out with them.
Sign up here
Look forward to seeing you there
——————————————————————————————————————————————————-
This event will feature:
- Wednesday night pre-event networking reception beginning at 7:00 p.m. at National Motorcycle Museum – hosted by Veeam Software
- Keynote with Joe Baguley – VMware Chief Cloud Technologist
- Exhibitor area with:
- VMware partners
- PowerCLI Drop In Area
- Expert Bar
Meeting Agenda
8:00 AM Registration
Breakfast, Mingle with Vendors8:30 – 9:00 AM VMUG Introduction and Wecome from VMUG Steering Committee 9:00 - 10:00 AM Keynote
Joe Baguley – VMware Chief Cloud Technologist10:00 – 10:15 AM Break, Mingle with Vendors 10:15 – 11:00 AM Partner Sessions Hitachi Data Systems
Accelerating your Cloud InfrastructureSymantec
Backup Exec and VMware: Best PracticesXangati
Blame Wars: The VI Admin Strikes BackActifio
Virtualization comes to Data Management11:00 – 11:15 AM Break, Mingle with Vendors 11:15 AM – 12:00 PM Community Sessions Duncan Epping/Frank Denneman – vSphere 5.0 Clustering Q&A Cormac Hogan vSphere 5.0 New Storage Features Dan Watson Security in the Virtual World Julian Wood vSphere 4->5 upgrade 12:15 – 1:00 PM Lunch, Mingle with Vendors 1:00 – 1:45 PM Partner Sessions Xsigo
Under the Hood with Virtual I/O Technology, and How VMware Uses It to Do MoreVeeam
Virtualization Data Protection, It’s Not Niche AnymoreArista Networks
Integrating Private and Public Clouds with Real World Networks1:45 – 2:00 PM Break, Mingle with Vendors 2:00 – 2:45 PM Community Session Duncan Epping/Frank Denneman – vSphere 5.0 Clustering Q&A Cormac Hogan vSphere 5.0 New Storage Features Dan Watson Security in the Virtual World Simon Gallagher vTardis 2:45 – 3:00 PM Break, Mingle with Vendors 3:00 – 3:45 PM Partner Sessions Coraid
Server Virtualization Demands a New Storage ArchitectureCommVault
Protecting and Managing Data in Growing VMware EnvironmentsEmbotics
Live Demonstration: Transforming Private Cloud Hype to Private Cloud Doing3:45 – 4:15 PM Mike Laverick – Cloud Journey – Bumps in the Road 4:15 – 4:30 PM Wrap-up & Prize Drawing -
PowerCLI-Man at VMworld Europe
Posted on October 5th, 2011 No commentsIf you are not already aware of the phenomenon that is PowerCLI-Man, well, where have you been? My sources tell me he may be making an appearance at VMworld Europe, so if you are not already going, I highly recommend you attend. In particular I would encourage you to attend VSP1882 or VSP1883 for your best chance to see him………
PowerCLI @ VMworld Europe from Alan Renouf on Vimeo.
-
Time for a change: Let’s go!
Posted on September 6th, 2011 1 commentI have really enjoyed my time at my current employer, there are some amazingly talented people who work / have worked there during the time I have spent there. However, for various reasons I have decided that it is time to move on and try something different by going freelance contracting. So while I work out my notice period I will be looking for a contract as my next opportunity.
Think about hiring me because of the following:
Achievements:
- VMware vExpert 2011
- Microsoft MVP for Windows PowerShell 2010 & 2011
- Co-author of the PowerCLI book (VMware VSphere PowerCLI Reference: Automating VSphere Administration)
Key Skills:
- VMware vSphere 4.1, 4.0 and ESX 3.5 – 4 years
- PowerShell / PowerCLI Scripting – 4 years
- Windows Server 2008 R2, 2008, 2003, 2000 and NT4(!) – 14 years
- Citrix XenApp 5.0, 4.5 and 4.0 – 3 years
- Active Directory and Exchange Migrations – 14 years
Highlight Projects:
- Virtualising Tier 1 Apps, including Citrix, Exchange, Sharepoint, Active Directory, SQL and SAP bringing significant cost savings and greater flexibility to the business.
- Automating virtualised environments with PowerCLI and PowerShell, saving time and money in operational costs.
- Moving virtualised environments to new datacentres with little or no downtime.
- Migrating through the versions of vSphere, from ESX 3.5 through ESXi 4.1.
- Implementing procedures around virtualisation to bring business benefits.
- Large scale P2V projects with subsequent big reductions in power, cooling and hardware requirements.
Certifications:
- VMware Certified Professional (VCP) 4.0 and 3.5
- Microsoft MCITP: Enterprise Administrator Windows Server 2008
- Microsoft MCSE – Windows 2003, 2000 and NT 4
- Citrix Certified Administrator (CCA) for Citrix XenApp5
So if you might be interested in taking me on for a contract based on these skills and experience, and the occasional ability to make people laugh, then you can contact me either via:
or
.
-
Download the PowerCLI 5.0 Poster
Posted on September 5th, 2011 No commentsThe PowerCLI team publish very handy reference posters that will sit nicely by your desk and usually release a new version to accompany each product release. vSphere 5 is no different and if you weren’t lucky enough to attend the recent VMworld and collect a tangible copy then you can now download one to print out yourself.
-
Using PowerCLI VIProperties and the VIProperty Module
Posted on August 18th, 2011 No commentsIn PowerShell it is possible to use custom properties for an object if the one you need does not exist by default – these are known as calculated properties.
For instance, in PowerCLI by default there is no ToolsVersion property for a VM, however we can create a calculated property named ToolsVersion and submit an expression to retrieve that data:
Get-VM TEST01 | Select-Object Name,@{Name="ToolsVersion";Expression={$_.ExtensionData.Config.Tools.ToolsVersion}}However, the ToolsVersion property does not persist after running this command, so if I now try:
Get-VM TEST01 | Select-Object Name,ToolsVersion
The ToolsVersion is not returned since PowerShell is not aware of that property. I would need to specify the expression again if I wanted to use it.
PowerCLI 4.1 introduced the new cmdlet New-VIProperty which allows you to create custom properties for an object. However, these properties will persist for the course of the current PowerShell session. Using the same example as above we can create a ToolsVersion property like this:
New-VIProperty -Name ToolsVersion -ObjectType VirtualMachine -ValueFromExtensionProperty 'config.tools.ToolsVersion’ -Force
So now I can run this query and this time I will get the results I was hoping for:
Get-VM TEST01 | Select-Object Name,ToolsVersion
The possibilities for using New-VIProperty are almost limitless. Luc Dekens has done a great job of collating a large set of community efforts of these on his VIProperties page . I have been using them a lot recently, either those already submitted, or creating my own, but was finding it frustrating copy / pasting each one in as and when required.
So instead I decided to put them all into a PowerShell module so that each of them would be potentially available at any time, simply by importing the module. A PowerShell module can be as simple as a collection of functions or scripts that are bundled up together and then imported to make them available for use.
I sent this to Luc, he thought it was a good idea too. So after tidying it up a bit, you can now download it from his site . Once downloaded and before unzipping the files, make sure to unblock the content before extracting it, otherwise you will have an issue when importing the module, dependent on your current PowerShell Execution policy:
Copy the extracted VIProperty folder to your PowerShell modules location – you can find this with:
$env:PSModulePath
Now you can make all of those VIProperties available by importing the module:
Import-Module -Name VIProperty
For instance I could combine some standard (Name, NumCPU) and custom properties (BootDelay,NumVirtualDisks) from the module in this query:
Get-VM Test01 | Select-Object Name,NumCPU,BootDelay,NumVirtualDisks
I highly recommend PowerCLI users check this out and please help make the module even more useful by submitting your own custom properties to Luc for inclusion.






















