A colleague requested some assistance as to whether it was possible to configure the vSphere Cluster Setting ‘VM dependency restart condition’ via PowerCLI. If you’re not familiar with this setting, it can be found in the vSphere Client web interface by editing the vSphere Availability cluster settings:
Digging around in the ExtensionData of a Cluster object in PowerCLI got us close, but it would appear that this value is not currently visible.
I’ve posted previously regarding returning output from PowerShell scripts that have been invoked by Ansible playbooks:
https://www.jonathanmedd.net/2019/10/ansible-windows-and-powershell-the-basics-part-6-displaying-output-from-powershell-code.html
https://www.jonathanmedd.net/2019/07/returning-data-from-powershell-scripts-to-be-consumed-by-ansible-playbooks.html
I encountered an issue recently where noise from a particular PowerCLI cmdlet, Invoke-VMScript, was polluting the output returned from the PowerShell script to Ansible. Specifically it looked like the below, a mess of Invoke-VMScript across the screen:
This is because Invoke-VMScript is one of those cmdlets which displays progress to the console while it is executing:
As part of some automated deployment work for ESXi I was assisting a colleague with, they had hit an issue with an out of the box deployment of ESXi beginning with a blank password for the root account.
The automation tool of choice Ansible was using an SSH connection to ESXi to make the initial configuration and was blocked at the first step since it was unable to connect because the fresh ESXi install had no password set.
While putting together the PowerCLI book 2nd Edition we initially included in the proposed Table of Contents a chapter on vRealize Automation. However, it was fairly apparent that at that time (early 2015) there wasn’t a lot which could be done to fill out the chapter with good content. Firstly, most of the relevant content would be included in the vRO chapter, i.e. use vRA to call a vRO workflow to run PowerShell scripts.
…..well in Kindle format anyway :-) The paperback version will be available on 11th January in the US and 12th January in the UK and according to the publisher, apparently in book shops from the 19th January. Seriously, if you actually see one in a book shop then please send me a photo, since I’ve not seen that happen outside of a VMworld.
With my fellow authors, Luc Dekens, Glenn Sizemore, Brian Graf, Andrew Sullivan and Matt Boren, we spent the best part of 2015 putting this book together.
The original Project Onyx (also here) was a VMware Fling which intercepted calls between the C# vSphere client and vCenter and could translate things you did in the GUI client to code in your choice of languages; SOAP, C#, PowerCLI, and JavaScript. This was really useful if say a thing you needed to do was not yet covered by a PowerCLI cmdlet, or you wanted to try and make it faster by using Get-View, or you didn’t know how to code it in JavaScript for vRO.
Over the last few years I have built up a number of functions to use alongside the out of the box functionality in PowerCLI. I’ve posted some of the content before on this blog, but have at last got round to publishing all of the content that I am able to share, in a module available on GitHub - I’ve named it the PowerCLITools Community Module in the hope that some others might want to contribute content to it or improve what I have already put together.
There aren’t many occasions when you trip up in PowerShell because of something being case sensitive, it generally doesn’t happen since most things are typically not like that. I was working with the PowerCLI cmdlet Get-Task and in particular the ID parameter to do something like:
Get-Task -Id 'task-task-2035' I had originally found the ID via:
Get-Task | Format-Table Name,ID -AutoSize However, I received the error that no tasks of that ID were found :
We’ve been waiting for this a long time, but with the 6.0 release PowerCLI is now available as a module. Microsoft changed the way itself and third-parties should deliver PowerShell functionality back in PowerShell version 2 by offering modules. Previously in PowerShell version 1 additional functionality was available via snap-ins.
It’s not fully there yet, but some of the functionality is now available in a module. 6.0 will be a hybrid release, with the rest to follow later.
A requirement for a project I had was to zero the VMDK of all VM disks at the time of VM removal.
One consideration was to SSH into the host where the VM was located and use vmkfstools like the below on each vmdk to zero the disk.
vmkfstools –w /vmfs/volumes/<…>.vmdk
Looking for alternatives I found that the PowerCLI cmdlet Set-HardDisk has a ZeroOut parameter. Note the text from the help (version 5.