Not too long ago I wrote a blog article on my blog www.vtagion.com about automating the deployment and configuration of Log Insight using PowerCLI. I’ve had many people ask if there is a way to automate the import process of Content Packs as well. Is it Possible? Continue reading
PowerCLI has several cmdlets at your disposal for managing OS Customization Specifications. In our first post we showed you how to create new customization specifications, retrieve and change them, in our second post we covered a common use case, being able to work with network interface card mappings and now in this final post we will show you how to clone a customization specification and give you an end-to-end scenario showing you how to use it in a script.
Cloning customization specifications
PowerCLI also gives you the ability to clone a customization specification (which creates an identical copy). You can clone both persistent and non-persistent specifications. Cloning is useful when you want to duplicate your customization specifications across multiple vCenter Servers. Let’s say you are connected to 2 servers – “vc1” and “vc2” and you want to copy all your customization specifications from “vc1” to “vc2”. Here is how to do that:
Get-OSCustomizationSpec –Type Persistent –Server vc1 | New-OSCustomizationSpec –Server vc2 –Type Persistent
You can also clone a customization specification as a non-persistent one. This is useful when you will be applying this specification to multiple VMs and will need to change the NIC mappings for each VM. Here is how to create a non-persistent clone of a customization specification:
$clone = Get-OSCustomizationSpec –Name BasicWindowsSpec | New-OSCustomizationSpec –Type NonPersistent
PowerCLI has several cmdlets at your disposal for managing OS Customization Specifications. In the previous post we showed you how to create new customization specifications, retrieve and change them, in this post we will cover a common use case, being able to work with network interface card mappings.
Managing network interface card (NIC) mappings
One of the common things to use the customization specifications for is to configure the VM’s network adapters (e.g. static IP, DHCP, etc.). The part of the customization specification that handles the network adapters is the OSCustomizationNicMapping. Each OSCustomizationSpec can have zero or more OSCustomizationNicMappings associated with it – and each of them corresponds to a network adapter of the VM. In order for a customization to succeed – you need to have as many OSCustomizationNicMappings as the number of network adapters on the VM you are customizing. You will see an example for this later on.
PowerCLI offers 4 cmdlets for managing the NIC mappings of a customization specification – these are Get-, Set-, New- and Remove-OSCustomizationNicMapping. Creating a new OSCustomizationNicMapping is done through New-OSCustomizationNicMapping cmdlet. Since the NIC mapping is part of a customization specification – when creating one you need to specify the customization specification to which you want to add the new NIC mapping. This is done through the “-OSCustomizationSpec” parameter. With a single OSCustomizationNicMapping you can configure a network adapter to either use DHCP or static IP.
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”.