Category Archives: PowerShell

PowerCLI: Virtual Machine disk usage

Recently I have had a few comments on an old post I wrote showing a one-liner to get the VM’s disk sizes for each VM, I was asked if there was a way to export this information into a CSV file.

The easy answer is yes but what you need to do is build up a container and then add each part of the information to the container, this is quite common practice in PowerShell, its a great technique where you can basically build and populate your own information and then just add to it, once you are completed you can then take your container and export it to whatever format you wish, for example:

The one-liner mentioned in my previous post simply outputted the data one VM at a time to the screen, whilst this was great for looking at the information, when we try and export it things start to go wrong !

The new script, below, may take up more lines but is far more efficient and adaptable.

image

Continue reading →

PowerCLI on the iPhone

Well not quite but the next best thing, I have been putting off getting an iPhone for a while now, I have always been a Windows mobile man starting back with one of the first windows mobile devices around, these were always one step ahead of the other phones when it came to the gadgets and things I wanted to do with a phone.

Recently I have been thinking about getting rid of my HTC Topaz (Diamond II) and succumbing to the iPhone geeks in the office, especially when I saw this…

Sapien Technologies are just about to release the latest version of their iPhone app called “iPowerShell 2.0”, this is a great cmdlet reference, much like my pdf but with all the help files and cmdlets in a nice easy accessible application, how cool is that ! Continue reading →

PowerCLI: Scripting ESXi

As the service console is moved further away from the hypervisor, people are finding it harder to configure ESX in the same way as has been done in previous versions.

Moving forward the only way to do this really is by accessing ESXi through the API using scripting toolkits such as PowerCLI or the Perl toolkit.

There are two basic versions of ESXi “free” and “licensed”, the scripting toolkits are limited to read-only access for the free version of VMware ESXi. When the host is upgraded to vSphere Essentials, vSphere Essential Plus, vSphere Standard, vSphere Advanced, vSphere Enterprise, or vSphere Enterprise Plus these toolkits have write-access enabled and provide a scriptable method for managing ESXi hosts. Continue reading →

PowerCLI: Automating traffic shaping on portgroups

I was contacted by someone who needed to automate some changes to their virtual infrastructure, I can never resist a challenge so of course I agreed to help.

He worked for a Virtual Hosting platform who offer hosting at a low cost of entry.  Each customer where he works is provided with a dedicated  virtual machine, a public IP space in a logical VLAN.   As such his platform is currently 9 hosts, 190 VM’s and 60 Portgroups/VLAN’s. The platform is based on HP c700 Chassis with Cisco 3020 gig switches, with each “half” of the chassis trunked back to our core with a 2Gbps etherchannel. Each Blade’s “production” interface is connected to each “half” of the chassis at 1Gbps with originating VM id based load balancing. Continue reading →

PowerCLI: Comparing Clusters

A simple one-liner for today, I needed to check all our current clusters and ensure all the ‘Production’ clusters were set the same, now we could go to each one and look at the settings but in this wonderful PowerCLI world we live why would you do anything more than once ?

The code is simple:

Get-Cluster | Select Name, * -ExcludeProperty id, CustomFields, ParentId | Sort Name | Out-GridView

The Get-Cluster cmdlet gets all the cluster information and then we simple exclude a few of the items I am not really interested in and then push the output through Out-GridView to display a nice filterable table as below:

Cluster

Continue reading →

PowerCLI: Shutdown your Virtual Infrastructure

Imagine your Power intake to your rack has failed, imagine your UPS has kicked in but is about to run out of power, you need to quickly shut down all of your virtual infrastructure…. quick run !

Or, you could let PowerCLI do the work for you and help you safely shutdown your entire virtual infrastructure, you could even tell your UPS software that when it gets to a certain amount of battery life left that it needs to run this script to safely shut things down.

Continue reading →

PowerCLI: Copying Advanced Host Configuration

I was asked in my script list comments if there was a way to copy the ESX host advanced configuration from one host to every other host in the cluster, thankfully PowerCLI gives us some nice cmdlets to work with that make this task very easy…

Get-VMHostAdvancedConfiguration and Set-VMHostAdvancedConfiguration

So first of all lets list the current advanced configuration of one of our hosts using Out-GridView:

Continue reading →

VESI & PowerGUI PowerPack V3

V3 Nodes

The popularity of this PowerPack never ceases to amaze me, as if it wasn’t enough to have more than 2500 downloads already it was also mentioned by the great Eric Sloof at the recent Dutch VMUG, check out a video of the session here (if you speak Dutch) or check out his slide deck here.

So, I have been working on V3 of the PowerPack and have just finished the final touches.

What’s new ?

To be honest I cant remember everything that is new but as you can see from the left hand node list there are a fair few new nodes which may help in your day to day admin life.

I have not only added my own enhancements but also included a bunch of bug fixes, (thanks Arnim and Luc) and also included some other scripts from Arne over at ICT-Freak.nl

I have re-organised some of the nodes so when you add the latest PowerPack you will receive a prompt like the below:

V3_Move_Nodes

Make sure you click yes to re-organise the nodes into the new areas.

I have also made a dependency on PowerCLI V4.0 Update 1 so if you do not have that version installed then please install it before upgrading to the latest PowerPack, you will not need vSphere 4.0 U1 as PowerCLI 4.0U1 is backward compatable.

In the latest version of PowerCLI VMware have made the connection methods a million times better, if you look at the code you will now see how easy it is to paste your new code into the nodes and create your own enhancements.

So what’s next for V4 ?  More of the same great scripts, more enhanced nodes, a move towards more actions and less nodes, and I am also thinking about opening this up as a community project, we can all add our own scripts to the PowerPack as a community effort and make this THE ULTIMATE FREE TOOL to have when administering or consulting VMware systems, express your interest via the comments please.

If your not a scripter but would like to see something in the PowerPack to make your life easier also please let me know via the comments.

Use the automatic update feature or download the new version now from below.

vSphere 4.0 Quick Start Guide – Available in Europe

Quick Start GuideThe vSphere Quick Start Guide is doing well, I don’t think we will quite take the Christmas Number 1 best seller slot but still, thanks to anyone who has purchased the book so far and a bigger thanks if you have left us a review or published a blog post, its always good to hear how people are finding the book.

After the release I had a few questions about when it would be released on the UK Amazon site, it seams that apart from sharing their name, these two sites do not have anything to do with each other, one would assume that once it was published on the US site it would soon make its way over to the UK site, that doesn’t seam to be the case.

Do not despair, we have now released it via LULU, a self publication site, you can now purchase the book and have it delivered very quickly from here for just…

£12.53 – no I am not missing a 0, that is correct, what a bargain price !

Continue reading →

Local Plugin Creator

Recently VMware are adding everything into vCenter to be centrally managed, apart from my PowerCLI prompt I think the vSphere Client is the second most launched application on my computer !

Now wouldn’t it be useful if you could add your other management interfaces into the vCenter Client, even if the vendor hasn’t created a plugin…

One App to rule them all, One App to find them,
One App to bring them all and in the vSphere Client bind them.

Sorry, couldn’t resist it. Continue reading →