Virtually everything is poshable
Posts tagged VI Toolkit
London VMUG – Thu 15 July – Lets get interactive !
Jul 12th
I have been given my normal resident slot at the London VMUG this Thursday, 15th July.
At the last VMUG I showed how vEcoShell could be used to add the graphical interface back onto our PowerCLI scripts and also gave an overview of the “VMware Community PowerPack”, when performing the demo I showed how easy it was to drill down into an object using the debugger in the script editor.
Someone asked me if next time I would give more tips and tricks like this, the kind of tips you pick up without realising it and are really helpful to people starting to learn PowerCLI.
So this time there will be a change in the way my session is presented…. We are going to get interactive !
If you are attending my PowerCLI session at the VMUG this Thursday 11-12, please bring along the following equipment:
- Laptop, Windows is preferable but if you have to use one of them Mac things please make sure you have a Windows VM.
- Pre-install Windows PowerShell V2
- Pre-Install PowerCLI 4.0 U1
- Pre-Install vEcoShell and vEcoShell Script editor.
I will bring these on a USB stick also but it will help if you are already setup and raring to go !
My plan is to host a ESX host and a vCenter VM and a few other VMs which we can all hook into and mess with, we can all do the same things and learn at the same time, I will have some mini instructions to follow which will help you along the path – think of this as a free PowerCLI course !
We will start off slow and then I will ask you to do a few things on your own, just to keep you awake.
Hopefully it will go down without a hitch, if you are unable to bring your laptop don’t worry I will try and put you in a group with other people so we can all observe and work together.
See you on Thursday and please remember your laptop !
Goodbye Virtu-Al – Hello Community
Jun 4th
This may not be news to some of you as I have mentioned it at both the Dutch VMUG and the London VMUG but anyway, if you were not lucky enough to make it to these because you live in a far away place then please read on…
The Virtu-Al PowerPack is no more – gone, dead and buried – RIP
However, the “VMware Community PowerPack” has arrived ! Yes it is a rename but also there is new content and a whole lot more to come, to give this the justice it needs I have created a landing page for the PowerPack at the top of my site under featured scripts or click here.
On the landing page you can see how to download it, a video showing how to install it and also how you can get involved in making it even more useful – Come on people we are all managing the same VMware software here !
Don’t worry if you don’t have scripting skills, you can still get involved !
And with great people like the below already adding content it is destine for great things !
Head over to the landing page http://www.virtu-al.net/featured-scripts/vmware-powerpack/ and check out the “VMware Community PowerPack” now !
Why vEcoShell or PowerGUI makes sense
May 7th
A little while back I started a PowerPack which could be used in either PowerGUI or vEcoShell – the application formerly known as “The Virtualisation EcoShell or VESI, my PowerPack was a collection of the most used scripts from my site all laid out in a nice GUI format.
Now why would you put a GUI back on top of the scripting, lets think about this…
vCheck v5
Mar 26th
That’s right, its finally here, vCheck v5 has arrived !
If you have been using previous versions of this report then its time to update, I have added lots of cool new features and checks which make this report (even if I do say so) awesome !
Some of the highlighted features of v5 are:
Comments
Each section now has comments telling you why I think it may be an issue, there are often links to blog posts and useful information for further reading, an example is below:
Obviously for the experts among you these comments can easily be removed in the script by changing the $comments = $true to $false
Automatic searching for log warnings
There is now a handy link to both the VMware KB site and Google which will automatically search for the errors found on these sites, no longer do you have a reason for not investigating those errors !
Multiple new checks
There are so many new checks that I have now created a dedicated page on my site for this script which lists some basic information, this will of course change over time as more detail is needed and I hope to shoot some video soon showing how to change some of the key areas.
To access the page click the “Featured Scripts” area above and select “vCheck (Daily Report)” or click here.
Thanks
I have been bugging various people to help me with this script, whether it be for information or html help, thanks to everyone who helped me out and also to the beta testers.
To mention a few of the people specifically, thanks goes to:
Raphael Schitz – As always he has contributed some great checks for v5 and thought of areas I would never have. Amazing job my friend.
Duncan Epping – I have bothered him more than once for clarification on the way things work, cheers mate.
Andy Grant – He did a great job helping me tidy up my HTML and add new areas.
The beta testers – you know who you are !
Sorry if I missed anyone !
Dell ESXi Management
Mar 17th
Unlike the traditional ESX software, the ESXi software does not have a service console. It helps reduce the installation footprint of the software and can allow the hypervisor to be directly installed on the system’s internal flash storage or a USB key.
At the moment I am investigating moving to ESXi from ESX, after resolving the DSET issue I was then faced with the management of the ESXi hosts, currently the full fat ESX hosts have the Dell open management agent installed on them and SNMP configured, this allows the Dell management server to keep track of the underlying hardware and report any hardware issues or firmware updates.
But what happens with ESXi 4.0 and the removal of the service console ?
Earlier with ESXi 3.5, OpenManage component were integrated with the downloadable Dell ESX3i ISO image
but from ESXi 4.0 onwards, VMware introduced a new concept called vSphere Installation Bundle (VIB), this allows the end users to download VIB files and install it directly into ESXi 4.0. Dell are now posting their OpenManage component as a VIB on support.dell.com.
To help reduce the system footprint and to simplify deployment, the ESXi software does not have a traditional service console management interface where Dell OpenManage agents are installed. Instead, to provide the required hardware manageability, VMware has incorporated the standard Common Information Model (CIM) management profiles into the ESXi software.
Getting started with the Update Manager Cmdlets
Mar 11th
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
Mar 3rd
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
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 !
PowerCLI: Technical Support Mode
Mar 1st
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
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
Feb 26th
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 >
Who created that VM ?
Feb 23rd
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:
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
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







(3)
(13)
(0)