How to run View PowerCLI

During my recent presentation at the 20th VMUGBE+ session, I showed different ways to run View PowerCLI cmdlets and scripts.

Several of the methods I showed, are already discussed on other blogs (to which I will include the links of course), but there is a new PowerShell feature that hasn’t been used until now (afaik).

view5

And since I never found a complete overview of all the available methods, I decided to create this post.

Continue reading How to run View PowerCLI

Rename an ESXi 5.x host

Another one from the PowerCLI Community. User internetrush1 wanted to know how he could rename an ESXi server through PowerCLI.

esxi-rename

In fact I was amazed there obviously is no cmdlet nor scripts available to perform this rather basic task. Luckily I had some code snippets laying around that did the job. Basically, I followed KB1010821 to do the ESXi 5.x host rename. But I decided it would be better to provide a real function to do the job.

Continue reading Rename an ESXi 5.x host

HL Tools – Part 2 – Create a Nested Hypervisor

During last year’s VMworld #NotSupported sessions one of the hot topics was William Lam‘s vInception talk. “Nested ESXi” has since then become indispensable in the homelab of everyone tinkering with virtualisation !

As a follow-up to that session, William posted several blog posts on the subject. You can find them all in a handy overview.

nested-esxi-sierpinski

But as much as I like his clear instructions on how to set up nested ESXi, I wanted to automate the process ๐Ÿ™‚ In my homelab I create, and remove, ESXi VMs on a regular basis. So with the “If you do it more than once, automate it” in mind, I decided to create a function for the process.

Continue reading HL Tools – Part 2 – Create a Nested Hypervisor

Find free SCSI LUNs

Another post that comes from a VMTN PowerCLI Community question. Jeff wanted to find the free SCSI LUNs in his environment.
While answering that thread I was amazed there was no PowerCLI function written yet to provide this functionality. At least that was what my friend Google told me ๐Ÿ˜‰

Since there exists a SDK method that makes retrieving free SCSI LUNs quite easy, the function I came up with isn’t too complex.

But it should help you in further automating the setup of your datastores.

Continue reading Find free SCSI LUNs

Game of Nines – VM Uptime Report

The end of the year is near again. Time to plan for the new, but also a time to look back on what was there in the past year.

Your vSphere environment is no different. It is time to produce some of those dreaded year reports that will show you how your environment has been doing. And one of the aspects a lot of people are very keen about, is the number 9 game ๐Ÿ˜‰

Game-of-Nines

What was the uptime of the VMs you had running ?

The question popped up on several occasions in the PowerCLI Community as well. So I guess I was not the only one that was looking for a way to calculate the uptime of Virtual Machines.

Bug alert ?: it seems that the PerformanceManager handles vMotions in a strange way. After a vMotion the sys.uptime.latest is reset to 0 (zero). That is understandable, since the VM is now running on a different ESXi host. But it seems that the aggregated metric do not add up all the sys.uptime.latest metrics from different ESXi hosts. So when you use DRS or do vMotions yourself, the produced report will have some serious flaws !

Continue reading Game of Nines – VM Uptime Report

Monitor the size of your vDisks

In a recent thread on the VMTN PowerCLI Community someone asked if it is possible to get historical hard disk statistics. I referred the user to my Datastore usage statistics post, where I showed how to use the “disk” metrics to get that information.

But getting the individual vDisk statistics is a bit more tricky compared to getting the datastore statistics, as I showed in that post. The “disk” metrics hold the information, but the Instance that points to the MoRef value of a VM makes it a bit more tricky to retrieve.

Be forewarned, the “disk” metrics hold usage data for all the vDisks that a specific VM has on a specific datastore. You will not be able to get individual vDisk statistics, unless the vDisks are stored on different datastores !

On the positive side, the “disk” metrics will allow you to see how your vDisks increase in size over time. For your Thick vDisks that increase will be by expanding them, and for your Thin vDisks it will also show the natural growth.

Continue reading Monitor the size of your vDisks

Work with E1000E NICs in PowerCLI

Now that Windows 8 and Windows Server 2012 are readily available , we all want to do some exploring. But if you want to automate the creation of some test VMs for this, you are in for a surprise.

The current PowerCLI 5.1 Release 1 doesn’t accept the E1000E NIC as a Type on the New-NetworkAdapter cmdlet. Users start hitting this limitation, as can be seen on this PowerCLI Community thread. You can go for the E1000, but why settle for less if you can easily script the use of the E1000E NIC from PowerCLI?

So even though Eric “the Scoop Meister” Sloof debunked the myth that the E1000/E1000E is faster than the VmxNet3, the E1000E is the default NIC type that vSphere gives you when you create a VM for a Windows Server 2012 or Windows 8 VM. Note that the E1000 apparently uses slightly more CPU resources than the E1000E. With the function in this post you can now automate this behavior.

Update November 17th 2012: In KB2006859 it seems to say that the VMXNET3 NIC doesn’t work with Windows Server 2012 or Windows 8. And there have been several blogs (including mine) that picked up this info. But after you apply the September 2012 patch to your ESXi servers, you can also use a VMXNET3 NIC for both Windows OS. See here and here for more info.

Thanks to reader alcapapower for drawing my attention to this (see his remark in the comments below).

Continue reading Work with E1000E NICs in PowerCLI

My favorite PowerShell editor is free now!

I rarely post about products, since I want to keep my blog “technical“, but there was some big news from Idera today.
As from version 4.6, their famous PowerShell Plus editor is now a free tool.

This is the editor I have been using to write, and debug, my PowerShell and PowerCLI scripts since day 1.

It would take me several pages to list the features I like and use in PowerShell Plus, but there are 2 that were ‘love at first sight’ for me; the Debug mode and the Variables pane. You can’t go without those when you are writing a script.

So why not give it a try, it’s for free now ๐Ÿ™‚

Belgian VMUG event #17, the “Blogger Edition”

Today was a historic day for the Belgian VMUG.

The 17th edition, the so-called “Blogger Edition“, was completely sold out. All 170 attendees, a new record, had a great day and the presentersย  all gave a peak performance. The list of presenters was impressive to say the least.

I was honored to have been selected to do a presentation as well. Since it was in Belgium, I decided to give the subject of my session a local twist. The subject was PowerCLI and beer, you can’t live without them.

You’ll be missing the story I told during the presentation, but on request, the slides.

Update: all presentations are now available here (requires a VMUG account).

Continue reading Belgian VMUG event #17, the “Blogger Edition”

Folder by Path

There seem to be many vSphere environments where the same foldername is used multiple times. A blue folder with the name Servers is quite common for example.

If you need to retrieve such a folder with the Get-Folder cmdlet, you will have to walk the path to the folder leaf by leaf and use the Location parameter. It would be handier if you could just specify the path to the folder and retrieve the folder like that.

The following is a small function that will allow you to do just that.

Update August 6th 2020: The missing NoRecursion switch caused folders by the same name, further down in the hierarchy, to be returned as well.

Update July 5th 2019: The functions have been updated to support the situation where a user is connected to multiple vSphere Servers.

Update February 18th 2016: In some situations the function might return folders with the same name from different location. Fixed by adding NoRecursion on line 48
Continue reading Folder by Path