Posts tagged vmware

Getting started with the Update Manager Cmdlets

Last night I needed to update some of my hosts with the latest patches that have been released recently, this gave me the ideal opportunity to look at the recently released VMware Update Manager cmdlets for PowerCLI.

For a full list of cmdlets or to download click here.

Whilst upgrading one of my hosts I shot a short video which will take you through some of the basics like:

  • Adding a baseline to a host
  • Scanning the host
  • Listing the patches which will be applied
  • Remediating a host

When watching the video don’t think about how you can do this to a single host, keep in mind that this could be run against multiple hosts or added to the end of a configuration script to ensure your hosts are up to date with the latest security patches after being deployed. More >

VMware Update Manager cmdlets

Way back beyond the time before PowerCLI was invented there was this app called the Virtual Infrastructure Toolkit, when you installed the VITK if you had Update manager installed you used to be able to install some beta cmdlets which worked with update manager, this was subsequently removed in future versions….. Until Now !

They are back from the dead and in the form of a separate download to the current PowerCLI installable.

Download and install them now !

The first thing you will need to check is what operating system you are installing these on, personally I did not check and ended up with an error when trying to install them on Windows 7 64bit so here is a list of the supported operating systems so you don’t make the same mistake: – OK I may have been using a modified version of PowerCLI – Apparently this does install on Win7 64bit, even if it isn’t in the supported list !

  • Windows Server 2008
  • Windows Vista
  • Windows XP Service Pack 2
  • Windows Server 2003 Service Pack 2

You will also need the following installed:

  • .NET 2.0 SP1
  • Windows PowerShell 1.0 or higher
  • VMware vSphere PowerCLI 4.0 Update 1

After installing, from the PowerCLI prompt we can see a list of the new cmdlets by using the Get-Command cmdlet as below:

Get-Command -PSSnapin VMware.VumAutomation

image

So we can see we have an extra 13 cmdlets, what do these do, well they do all the “Update Manager” type tasks you would expect to do, so now as well as deploying our hosts we can also make sure they are patched to the latest version before adding them into our cluster, all automated of course !

More >

PowerCLI: Technical Support Mode

Today Duncan over at yellow-bricks.com has started quite the conversation on technical support mode for ESXi or otherwise known as “unsupported mode”, check out his blog post and especially the comments here:  http://www.yellow-bricks.com/2010/03/01/disable-tech-support-on-esxi/

As always when I see a post my first thought is to PowerCLI, so how can it help in this instance, well apart from the obvious cmdlets which I mentioned in my earlier ESXi post, there are also a couple of one liners which can help us manage Technical Support mode.

To view all hosts and check to see if they have Technical Support mode enabled, use the following:

Get-VMHost | Where {$_.State -eq "Connected" -or $_.State -eq "Maintenance"} | Get-View | Where {$_.Summary.Config.Product.Name -match "i"} | Select Name, @{N="TechSuportModeEnabled";E={(Get-VMHost $_.Name | Get-VMHostAdvancedConfiguration -Name VMkernel.Boot.techSupportMode).Values}} | Out-GridView

image

To disable it on all ESXi hosts use the following:

Get-VMHost | Where {$_.State -eq "Connected" -or $_.State -eq "Maintenance"} | Get-View | Where {$_.Summary.Config.Product.Name -match "i"} | Get-VIObjectByVIView | Set-VMHostAdvancedConfiguration -Name VMkernel.Boot.techSupportMode -Value $false

And to enable it use the following:

Get-VMHost | Where {$_.State -eq "Connected" -or $_.State -eq "Maintenance"} | Get-View | Where {$_.Summary.Config.Product.Name -match "i"} | Get-VIObjectByVIView | Set-VMHostAdvancedConfiguration -Name VMkernel.Boot.techSupportMode -Value $true

Thanks to Duncan and his most excellent site for the constant source of script ideas ;)

London VMUG – My Presentation

Yesterday was a fantastic VMware user group, definitely my favourite one so far, lots of great content from some fantastic people and some real rockstars (I think that is the 2010 word for Guru’s) like Mike Laverick, Carter Shanklin (Carter USM), Stuart Radnidge and many many more.

I was privileged to open the show with a PowerCLI session, this is a pre-show session so wasn’t really part of the main VMUG, as such I was not expecting such a large crowd, if you came to the session then thanks very much, i thing there must have been around 40-45 people in there and I had a great time presenting this one.

We had a great mix of beginners to Pro’s and some great conversations about PowerCLI and what we could do to take the ESX install to the next level, one such example is in my script where we add an A host record to the DNS server as part of our deployment.

If you weren’t there or you would just like to re-live the presentation then please see below: More >

Virtualising XenApp – What’s the magic number ?

In the past I have virtualised a number of different applications and types of servers, among these have been several Citrix WinFrame/MetaFrame/Presentation Server or as it is currently known XenApp Servers.

Recently I have been asked about this on a number of occasions and the question is always the same:

How many users can you get on a Virtualised XenApp Server ?

That’s like saying how long is a piece of string ! – The answer to this question is the same to most IT related questions I get asked…. It depends !

To be able to give this subject the full attention that is needed I plan on creating a series of blog posts which will enable us to discuss the different configuration types and I will hopefully aid you in working out what your magic number is, how many users you can get on a virtual XenApp server.

The series of blog posts will probably change as I start to delve into the different subjects but all will eventually link from this post.

Introduction
Why Virtualise XenApp ?
Design Factors
•    Sizing
•    Citrix Desktops
•    Seamless Applications
•    Redundancy
•    Licensing
•    Cost Cutting
Testing
•    Strategy
•    Applications
•    Tweaking
Implementation
•    Templates
•    Deployment
Monitoring
Upgrade strategy

Hopefully this will help with some of the questions I have received recently, if there is anything missing which you would also like me to include then please do let me know via the comments of this post !

If you are also into podcasts then make sure you listen to the recent discussion I had with the Chinwagger himself – Mike Laverick, this can be found on his blog here.

Who created that VM ?

I was asked whilst on a customer site to work out who had created a VM, this is a common question in most environments where admin rights are the normal and creating a VM is as easy as creating a new word document.

After trawling through the logs for a couple of minutes I found the creator and told the customer, easy enough I guess but how could we make this easier ?

The answer to that question will be no surprise to most readers of this blog….. PowerCLI !

With a quick script and resolving the user account in AD, I was able to add a custom field to each VM letting me know who created the VM and when it was created, all displayed in the annotations of each VM as seen below:

image

Connect-VIServer MYVISERVER
# Uncomment the next line to test this script and tell you what it would do !
# $WhatIfPreference = $true
if (-not (Get-PSSnapin VMware.VimAutomation.Core -ErrorAction SilentlyContinue)) {
	Add-PSSnapin VMware.VimAutomation.Core
}
if (-not (Get-PSSnapin Quest.ActiveRoles.ADManagement -ErrorAction SilentlyContinue)) {
	Add-PSSnapin Quest.ActiveRoles.ADManagement
}

$VMs = Get-VM | Sort Name
$VM = $VMs | Select -First 1
If (-not $vm.CustomFields.ContainsKey("CreatedBy")) {
	Write-Host "Creating CreatedBy Custom field for all VM's"
	New-CustomAttribute -TargetType VirtualMachine -Name CreatedBy | Out-Null
}
If (-not $vm.CustomFields.ContainsKey("CreatedOn")) {
	Write-Host "Creating CreatedOn Custom field for all VM's"
	New-CustomAttribute -TargetType VirtualMachine -Name CreatedOn | Out-Null
}
Foreach ($VM in $VMs){
	If ($vm.CustomFields["CreatedBy"] -eq $null -or $vm.CustomFields["CreatedBy"] -eq ""){
		Write-Host "Finding creator for $vm"
		$Event = $VM | Get-VIEvent -Types Info | Where { $_.Gettype().Name -eq "VmBeingDeployedEvent" -or $_.Gettype().Name -eq "VmCreatedEvent" -or $_.Gettype().Name -eq "VmRegisteredEvent" -or $_.Gettype().Name -eq "VmClonedEvent"}
		If (($Event | Measure-Object).Count -eq 0){
			$User = "Unknown"
			$Created = "Unknown"
		} Else {
			If ($Event.Username -eq "" -or $Event.Username -eq $null) {
				$User = "Unknown"
			} Else {
				$User = (Get-QADUser -Identity $Event.Username).DisplayName
				if ($User -eq $null -or $User -eq ""){
					$User = $Event.Username
				}
				$Created = $Event.CreatedTime
			}
		}
		Write "Adding info to $($VM.Name)"
		Write-Host -ForegroundColor Yellow "CreatedBy $User"
		$VM | Set-CustomField -Name "CreatedBy" -Value $User | Out-Null
		Write-Host -ForegroundColor Yellow "CreatedOn $Created"
		$VM | Set-CustomField -Name "CreatedOn" -Value $Created | Out-Null
	}
}

The script is fairly straight forward, a few caveats are worth mentioning though:

  • This script uses the Quest AD cmdlets to resolve the username in AD, if you don’t have these installed then you can either install them or use the Microsoft AD cmdelts or I have a small function which will do the same thing, I previously used this here.
  • This may take a long time if the VM was created a long time ago as unfortunately the Get-VIEvent cmdlet does not have a way to start from the beginning of the events so I need to retrieve all events for that VM and then filter on them.
  • If the VM’s were removed from the virtual center and then re-added it will have the name of the person who re-imported or added the VM, not the original creator.

Once we have the information added to the VM’s we can of course do some cool reporting, like who created the VM’s:

Get-VM | Select Name -ExpandProperty CustomFields | Where {$_.key -eq "CreatedBy"} | Out-GridView

image

Or even who created the most VMs:

Get-VM | Select Name -ExpandProperty CustomFields | Where {$_.key -eq "CreatedBy"} | Group-Object | Select Count, Name | Sort Count -Descending |Out-GridView 

image

London VMware User Group – 25th Feb

I have been asked to do a session at the London VMUG on 25th February 2010, after my previous session where I took the attendees through a beginners introduction to PowerCLI, I think I will throw them straight in this time and show them how we can configure ESXi using PowerCLI.

ESXi is obviously a hot topic at the moment and the configuration of ESXi without the service console access is proving to be difficult for many users.  This session will take you through the configuration of a host from start to end showing you how easy it is and highlighting some of the scripts and cmdlets explained in my previous post.

image

 

As a bonus I will also be giving away a set of “VMware vSphere Pro Series Training Vol. 1: View, ThinApp, Nexus 1000V, and PowerCLI” videos during my session, with thanks to the great guys at TrainSignal, be sure to bring your questions along for a chance to win this great prize !

 

There will obviously be all the other great sessions which normally take place and there is even a rumour that an all powerful PowerCLI expert from the states will be descending from upon high to give us the latest and greatest automation information from VMware !

I am personally looking forward to a “Real life” session which my colleagues Jonathan Medd and Vic Milne will be delivering, this will be an interesting presentation on how they moved both datacenters and storage devices with (nearly) no downtime !

Also on my agenda will be the Enterprise Cloud presentation from vStu that is sure to be full of both useful information in a friendly and native Australian dialog and humour.

As always the details for the VMUG can be found on the forum here.

If you are looking to deploy ESXi and are having trouble performing or have had trouble performing a certain task then please do let me know via the comments of this post so I can be sure to include this. – It would also give you bonus points when in the running for the TrainSignal video :)

PowerCLI: Configured Maximums – Storage

With vSphere introduced some new maximum’s which we not only have to memorise for the exams but also have to keep in mind when designing and using your infrastructure.

In the back of your mind when adding a new host to a cluster you should always be thinking, how many hosts should be in this cluster ? or when adding another LUN to your clustered hosts, how many datastores should I have as a maximum before it starts impacting my performance and how many paths are supported ?

The answer to these questions (in my case anyway) is to use PowerCLI to check them :)

I will of course add these to the next version of vCheck so they are automatically checked for but in the meantime here are some quick one-liners to check your infrastructure against the configured maximums for storage, I will add more as I write them:

More >

PowerCLI: How many HBA’s ?

I needed a quick one-liner today to help me find out how many HBA’s my hosts had, the following one-liner needs no more introduction:

Get-VMHost | Select Name, @{N="FibreHBAs";E={($_ | Get-VMHostHba | Where { $_.Type -eq "FibreChannel"} | Measure-Object).Count}} | Out-GridView

Output:

image

More >

LucD-2 here to help PowerShell self evolve

Untitled

For the PowerCLI lovers out there you may want to check out the recent Get-Scripting Podcast.

This month Jonathan and I have interviewed the master of PowerCLI himself, Luc Dekens or LucD on the forums and LucD22 on twitter.

Anyone who has ever visited the PowerCLI forums will know who Luc is, he also has an amazing blog with great walkthroughs on some of the more complicated PowerCLI areas including the SDK, events and alarms.

The rumour is that Luc is actually the next version of a terminator robot, here to help PowerShell self evolve, if you are interested in PowerCLI or automating VMware then please download episode 15 of the Get-Scripting podcast here:

http://get-scripting.blogspot.com/2010/02/get-scripting-podcast-episode-15-luc.html