powershell

Clone a VM from a Snapshot using PowerCLI

A colleague asked me whether it was possible to clone a VM from a particular snapshot. Since there is no capability to do this via the GUI, I looked at what was possible via other means, i.e. PowerCLI. The vSphere API contains a Clone_VM task, which includes the ability to specify a snapshot to clone from in the VirtualMachineCloneSpec. So I put together the below New-VMFromSnapshot function to make this easy to do for a few different scenarios - it supports multiple snapshots to choose from, full and linked clones, and multiple destinations such as cluster, datastore, VM folder:

PowerShell Deep Dives - Published!

I’m very pleased to announce that the book I contributed a chapter to, PowerShell Deep Dives, has been published! It’s available as a pre-order for the paper version, the electronic version is available now, with ePub and Kindle versions to follow soon. Congratulations to my fellow editors and authors; some many great contributions from the PowerShell community: Editors Jeffery Hicks, Richard Siddaway, Oisín Grehan, and Aleksandar Nikolić are joined by PowerShell experts Chris Bellée, Bartek Bielawski, Robert C.

@LucD22 talks to @GetScripting About Becoming a PowerShell MVP And His Upcoming PowerCLI Book

We were fortunate enough to get a bit of a scoop on the latest episode of GetScripting . Not only did we have chance to talk to Luc Dekens about recently becoming a PowerShell MVP, but he also gave us a bit of a scoop about his upcoming new book (due out in 2014), vSphere Performance Reporting with PowerCLI . Hopefully they’ll change the cover typo by the time it gets printed :-)

Obtaining CDP info via PowerCLI

There are quite a few posts out there already on this topic and in fact the official VMware KB article has a suggestion on how you can get CDP info via PowerCLI. I didn’t really like the way they presented the code though so I made my own function Get-VMHostNetworkAdapterCDP in the typical style with pipeline input and object output A typical use case: Get-VMHost ESXi01 | Get-VMHostNetworkAdapterCDP would see the following output

Making Native Executables in Windows Run Quietly in PowerShell

Sometimes it can still be beneficial to use a native Windows executable rather than a PowerShell cmdlet, either because say the cmdlet doesn’t exist yet or doesn’t have the functionality that you require. Many of these executables though won’t behave in the way you have become accustomed to PowerShell cmdlets behaving - for instance some maybe noisy in terms of their output. Take for instance OpenSSL.exe. I was using this the other day to generate some certificates and it’s pretty noisy on its output.

Using PowerCLI for iSCSI VMKernel Port Binding

I was surprised to discover that there were no native cmdlets for managing iSCSI VMKernel Port Binding in PowerCLI. So I made my own Get-VMHostiSCSIBinding and Set-VMHostiSCSIBinding functions and have shared them here in case anyone else finds them useful. Here’s a couple of examples of how they can be used: Retrieve iSCSI Port Binding details Get-VMHost ESXi01,ESXi02 | Get-VMHostiSCSIBinding -HBA "vmhba32" | Format-Table PortGroup,Vmknic,IPv4,IPv4SubnetMask,MACAddress -AutoSize 2) Set iSCSI Port Binding details

UK PowerShell UserGroup needs your feedback on future events

The UK PowerShell UserGroup has been running for around 6 years now, but has been a little quiet of late. My fellow PowerShell MVP Richard Siddaway is currently seeking feedback on how you might like to see the group develop in the future. So if you have attended in the past or would consider attending a future event, please give him your feedback and help shape the direction it takes.

Migrating Email Alarm Actions between vCenter 5.0 and 5.1

I needed to migrate some Email Alarm Actions between two vCenters; the target at version 5.1 being a replacement for an existing 5.0 vCenter. The first task was to identify which Alarm Definitions had been configured with an email alert. To do that I used the following PowerCLI command to export them to a CSV file: Get-AlarmDefinition | Select Name,@{N="EmailAction";E={$\_ | Get-AlarmAction | Where {$\_.ActionType -eq "SendEmail"}}} | Export-Csv AlarmActions.csv -NoTypeInformation I could then easily identify those which needed to be migrated across.

Using PowerCLI to set ESXi Dump Collector Settings

I needed to check the configuration of all hosts in an environment for their ESXi Dump Collector Settings and then ensure they were all set to the correct values. I was using the handy ESXi Dump Collector which ships as part of the vCenter 5.1 package. There are no PowerCLI cmdlets for doing this (yet) so I made my own, Get-VMHostDumpCollector and Set-VMHostDumpCollector. Since you can get and set this item via esxcli I used the Get-ESXCli cmdlet for most of the work.

Using PowerCLI for Advanced Syslog Configuration Tasks

PowerCLI has shiped with cmdlets for managing the Syslog configuration of ESXi hosts for some time, Get-VMHostSysLogServer and Set-VMHostSysLogServer. Unfortunately, neither of these (yet) support the configurations mentioned in the below two posts for multiple Syslog servers or different protocols, such as SSL. http://www.boche.net/blog/index.php/2011/07/23/configure-a-vcenter-5-0-integrated-syslog-server/ http://blogs.vmware.com/vsphere/2012/04/configuring-multiple-syslog-servers-for-esxi-5.html So for the time being I have put together two functions, Get-VMHostSyslogConfig and Set-VMHostSyslogConfig, to supplement what you can currently do with the following additional options: