Skip to content

PowerCLI

Convert-ScsiCode PowerShell Function

The Convert-ScsiCode PowerShell function decodes SCSI sense codes found in the vmkernel.log from ESXi hosts. It uses a JSON based SCSI Code database provided by virten.net. The function works just like my web-based SCSI Sense Code Decoder but allows you to integrate it in your automation scripts.

The function is part of my Virten.net.VimAutomation module, which is a set of PowerShell function built for managing, troubleshooting and automating VMware based platforms. The module can be easily obtained from the PowerShell Gallery and is available on GitHub.

Read More »Convert-ScsiCode PowerShell Function

How to use ESXCLI v2 Commands in PowerCLI

PowerCLI, a set of PowerShell extensions for vSphere, is a great tool for automating VMware configuration and management tasks. It allows you to change a lot of ESXi host and vCenter settings. A powerful cmdlet is Get-EsxCli which allows you to run ESXCLI tasks from your PowerCLI console. ESXCLI is the main configuration command on an ESXi host.

This post explains how to use the Get-EsxCli cmdlet with the new V2 interface, which is much more intuitive than the old method.

get-esxcli

Read More »How to use ESXCLI v2 Commands in PowerCLI

Getting Started with PowerCLI for Linux (PowerCLI Core)

powerclicoreBased on Microsoft PowerShell Core which enables users to use PowerShell on Linux, Mac and Docker, VMware has started to make PowerCLI compatible with the new PowerShell. This allows to run scripts that were previously only available for Windows on Linux or Mac based systems.

In this post I am going to give a quick startup guide to the installation and configuration of PowerCLI Core.

Read More »Getting Started with PowerCLI for Linux (PowerCLI Core)

How to properly initialize PowerCLI 6.x in PowerShell ISE

With the release of vSphere 6.0 VMware has started to transform their distribution model of PowerCLI cmdlets from PSSnapins into modules. This is a good thing because modules are the preferred method of adding cmdlets to PowerShell. Unfortunately the changed behavior breaks plenty instructions on how to load VMware PowerCLI in ISE, including my own. The old method works for core cmdlets, but functions related to Distributed Switches or Storage Policies for example are missing.

If you have the latest version of PowerCLI installed but cmdlets are missing in PowerShell ISE, maybe you are using the old method to load cmdlets.

Get-VDSwitch : The term 'Get-VDSwitch' is not recognized as the name of a cmdlet, function, script file, or operable program.

Read More »How to properly initialize PowerCLI 6.x in PowerShell ISE

vSphere 6.0 - How to use ESXCLI Commands in PowerCLI

PowerCLI, a set of PowerShell extensions for vSphere, is a great tool for automating VMware configuration and management tasks. It allows you to change a lot of ESXi host and vCenter settings. One powerful cmdlet is Get-EsxCli which allows you to run ESXCLI tasks from your PowerCLI console. ESXCLI is the main configuration command on an ESXi host. This post explains how to use the Get-EsxCli cmdlet.

get-esxcli

Read More »vSphere 6.0 - How to use ESXCLI Commands in PowerCLI

Permanently disable ESXi 5.5 coredump file

The new coredump file feature in vSphere ESXi 5.5 creates a file to extend the coredump partition. This usually happens when you upgrade from a previous version to ESXi 5.5, or you install ESXi to a USB drive or SD card. This coredump file is created on a random VMFS datastoore by using a smart selection algorithm. This random placement causes different kind of problems, for example when you want to delete a datastore. Another problem might occur in an EMC VPLEX deployment where you want to failover VMs to the secondary site in a PDL situation (VMkernel.Boot.terminateVMOnPDL=1 / Disk.AutoremoveOnPDL=0). Datastores that had a coredump file configured can't get mounted back when the volume leaves the PDL state after a site failure has been fixed.

To workaround this issue you might want to permanently disable the coredump file. You can't just disable it, as it gets created automatically after a reboot.

Read More »Permanently disable ESXi 5.5 coredump file

VM Export/Import PowerCLI Script

I wrote this little script snippet to export and import virtual machines from one vCenter to another. This might help for migrations where you have to add virtual machines from a datastore manually to the vCenter inventory. This script does not export any virtual machine disks or configuration files. It's only supposed as replacement for adding virtual machines from an existing datastore the the inventory.

Read More »VM Export/Import PowerCLI Script