Auto Deploy and Image Builder profile functions

One of the best and one of my favorite ideas from the PowerCLI team (there are so many to choose from) was to include an initialization script when you launch PowerCLI, this gives us the nice black background, custom prompt and also other things like the Get-VICommand function.

Get-VICommand lists all the VMware related cmdlets added to your session, this is useful for quickly listing the VMware cmdlets you need, most people think this is actually a cmdlet which is part of PowerCLI but if you have ever imported the VMware snapin into a PowerShell session and tried to use Get-VICommand you will quickly realize this is not part of the cmdlet set.

This is actually stored in the initialization file added when PowerCLI is installed, in my setup it is stored in the following location:

C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1

If you open this file you will find some nice to have PowerShell code and particularly the following:

function global:Get-VICommand([string] $Name = "*") {
 get-command -pssnapin VMware.* -Name $Name
}

This brings me to the reason for this post, I have started playing with the PowerCLI cmdlets for Image Builder and Auto Deploy and whilst learning them I found it useful to be able to list the cmdlets as the naming wasn’t always obvious.

To do this, I added the following code to my PowerShell Profile  (read about PowerShell profiles here), it was suggested that I should blog this to make other people lives easier:

Function Get-DeployCommand {
Get-Command -Module VMware.DeployAutomation }

Write-Host -ForegroundColor Yellow "Added Function: Get-DeployCommand"

Function Get-ImageBuilderCommand {
Get-Command -Module VMware.ImageBuilder }

Write-Host -ForegroundColor Yellow "Added Function: Get-ImageBuilderCommand"

These will give you a cmdlet which lists the Image Builder cmdlets (Get-ImageBuilderCommand) and also the Auto Deploy cmdlets (Get-DeployCommand).

Another nice function to add is the following, this will allow you to easily add the VMware hosted software depot’s allowing easy access to the latest ESXi builds from VMware, I have named this Add-DefaultESXSoftwareDepot:

Function Add-DefaultEsxSoftwareDepot {
Add-EsxSoftwareDepot https://hostupdate.vmware.com/software/VUM/PRODUCTION/main/vmw-depot-index.xml
}

Write-Host -ForegroundColor Yellow "Added Function: Add-DefaultEsxSoftwareProfile"

One thought on “Auto Deploy and Image Builder profile functions”

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.