Home > Blogs > VMware PowerCLI Blog


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.

This entry was posted in Customization and tagged on by .
Alan Renouf

About Alan Renouf

Alan Renouf is a Product Line Manager at VMware focusing on API's, SDK's and CLI's, He is responsible for providing the architects and operators of private and public cloud infrastructure with the toolkits/frameworks and command-line interfaces they require to build a fully automated software-defined datacenter. Alan is a frequent blogger at http://blogs.vmware.com/PowerCLI a book author and has a personal blog at http://virtu-al.net. You can follow Alan on twitter as @alanrenouf.

7 thoughts on “Working with Customization Specifications in PowerCLI Part 1

  1. Pingback: Newsletter: June 1, 2014 | Notes from MWhite

  2. Pingback: Working with Customization Specifications in PowerCLI Part 2 | VMware PowerCLI Blog - VMware Blogs

  3. Pingback: Working with Customization Specifications in PowerCLI Part 3 | VMware PowerCLI Blog - VMware Blogs

  4. Joel Newton

    I do a lot of VM cloning, and I occasionally have cloned VMs where the customization specification never finishes getting applied. There is no success or failure VI event logged, and there are no errors in C:\Windows\Temp\vmware-imc\guestcust.txt. However, I can see that the new VM has not been renamed and hasn’t joined the domain.

    Can customization be interrupted if the new VM is VMotioned or changed somehow during the process?

    Thanks,
    Joel

    Reply
  5. Pingback: Crear múltiples Linux VMs de un fichero CSV usando PowerCli. Deploying multiple Linux VMs using PowerCli version 1.3 – VIDANEZ SITE

  6. Tanveer Ahmed

    could you pelase provide an example on what should be the structure of the spec parameter in the New-OSCustomizationSpec as i could not find any in the Microsoft documentation.

    Reply
  7. Vinod

    During VM creation I have used New-OSCustomizationNicMapping. First NIC has gateway IP and for second NIC, I do not want gateway IP. But I get error that if I use ‘UseStaticIp’ then command requires gateway IP. Can you please help me ASAP.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

*