Customization

Working with Customization Specifications in PowerCLI Part 1

PowerCLI has several cmdlets at your disposal for managing OS Customization Specifications. In this post you will learn in more detail how to use them. In future posts we will discuss managing network interface card (NIC) mappings, cloning customization specifications and customizing VMs.

Managing customization specifications

Creating a new OSCustomizationSpec is done through New-OSCustomizationSpec cmdlet. You can create customization specifications for either Windows or Linux Virtual Machines. You specify the OS Type through the “-OSType” parameter of the cmdlet – the accepted values are “Windows” and “Linux” respectively.

When creating a Windows customization specification there are several mandatory parameters that you need to specify. These are: “Name”, “Domain” or “Workgroup”, “FullName” and “OrgName”.

Here is an example:

New-OSCustomizationSpec –Name “BasicWindowsSpec” –FullName “administrator” –OrgName “Organization” –Domain “vmware.com” –DomainUsername “user” –DomainPassword “pass” –OSType Windows

# Or, using Workgroup:

New-OSCustomizationSpec –Name “BasicWindowsSpec” –FullName “administrator” –OrgName “Organization” –Workgroup “MyWorkgroup” –OSType Windows

When creating a Linux customization specification the mandatory parameters are just “Name” and “Domain”:

New-OSCustomizationSpec –Name “BasicLinuxSpec” –Domain “vmware.com”–OSType Linux

Specifically for Linux customization specifications you can specify DnsServer parameter. The parameter accepts array of strings and the DNS servers you specify there are applicable to all network adapters of the VM. If you specify more than one value – the first one will become the primary DNS server, the second one – the secondary, and so on:

New-OSCustomizationSpec –Name “BasicLinuxSpec” –Domain “vmware.com”–OSType Linux –DnsServer “192.168.0.10”, ”192.168.0.20”

# In this case 192.168.0.10 will become the primary DNS and 192.168.0.20 – the secondary

In contrast – for Windows customization specifications you configure the DNS servers per network adapter. We will have a look at that later on.

Apart from the mandatory parameters you can also specify a variety of other settings. You can find all parameters with information about each of them in PowerCLI cmdlet reference.

The above examples create new customization specifications with the given names and save them on the server. Such specifications are referred to as “Persistent”. Once you create them they are persisted on the server and you can access them at any time, even from another PowerCLI session. You also have an option to create a “NonPersistent” specification – these are not stored on the server, but they are kept in-memory in the current PowerCLI session. Once the PowerCLI session is closed – these specifications are discarded. Later on we will demonstrate what the non-persistent specifications are useful for.

To create a non-persistent specification you need to specify that in the “–Type” parameter:

New-OSCustomizationSpec –Domain “vmware.com”–OSType Linux –Type NonPersistent

When creating non-persistent specifications you do not need to specify a name for them (you can if you want to).

To retrieve the list of existing customization specifications you can use the Get-OSCustomizationSpec cmdlet. It retrieves both persistent and non-persistent specifications. You can additionally filter the specifications by Name and/or Type (e.g. persistent/non-persistent):

Get-OSCustomizationSpec

Get-OSCustomizationSpec –Name BasicWindowsSpec

Get-OSCustomizationSpec –Type Persistent

You can modify an existing customization specification (whether it is persistent or non-persistent) by using Set-OSCustomizationSpec cmdlet. This allows you to change the parameters of the specification that were configured during its creation:

Get-OSCustomizationSpec –Name BasicWindowsSpec | Set-OSCustomizationSpec –TimeZone “Central (U.S. and Canada)”

You can find all parameters of the cmdlet in PowerCLI cmdlet reference, or by typing “Get-Help Set-OSCustomizationSpec” in the PowerShell console.

Removing a customization specification is done through Remove-OSCustomizationSpec cmdlet. The cmdlet will prompt you for confirmation before removing the object. If you don’t want to be prompted (e.g. when running a script) – you can suppress the prompt with –Confirm:$false:

Remove-OSCustomizationSpec –OSCustomizationSpec BasicWindowsSpec –Confirm:$false

clip_image002[8]This post was created by Dimitar Barfonchovski.

Dimitar joined VMware and the PowerCLI team in 2007. He is member of the development part of the team and his main responsibilities are the functional design and implementation of features for the vSphere and vCloud PowerCLI components.

As with all members of the team, he is working to deliver a good and valuable product. He is also working to improve all processes and tools involved in the product development and validation.