Using OS customization specifications

OS customization specifications are XML files that contain guest operating system settings such as the computer name, network settings, and license settings-for virtual machines. You can use OS customization specifications to modify the configuration of the operating system during the deployment of new virtual machines.

Let's get a list of the names of all the OS customization specifications cmdlets:

PowerCLI C:> Get-Command -Noun OSCustomization* |
>> Select-Object -Property Name

The output of the preceding command is as follows:

Name
----
Get-OSCustomizationNicMapping
Get-OSCustomizationSpec
New-OSCustomizationNicMapping
New-OSCustomizationSpec
Remove-OSCustomizationNicMapping 
Remove-OSCustomizationSpec
Set-OSCustomizationNicMapping
Set-OSCustomizationSpec

To create an OS customization specification or to clone an existing one, you have to use the New-OSCustomizationSpec cmdlet. This cmdlet has the following syntax. The first parameter set is for Linux operating systems:

    New-OSCustomizationSpec [-OSType <String>] [-Server <VIServer[]>]
    [-Name <String>] [-Type <OSCustomizationSpecType>] [-DnsServer
    <String[]>] [-DnsSuffix <String[]>] [-Domain <String>] [-NamingScheme 
    <String>] [-NamingPrefix <String>] [-Description <String>] [-WhatIf]
    [-Confirm] [<CommonParameters>]

The second parameter set is for cloning OS customization specifications:

    New-OSCustomizationSpec -OSCustomizationSpec <OSCustomizationSpec>
    [-Server <VIServer[]>] [-Name <String>] [-Type 
    <OSCustomizationSpecType>] [-WhatIf] [-Confirm] [<CommonParameters>]

The -OSCustomizationSpec parameter is required.

The third parameter set is for Windows guest operating systems:

    New-OSCustomizationSpec -FullName <String> -OrgName <String> [-OSType 
    <String>] [-ChangeSid] [-DeleteAccounts] [-Server <VIServer[]>]
    [-Name <String>] [-Type <OSCustomizationSpecType>] [-DnsServer 
    <String[]>] [-DnsSuffix <String[]>] [-GuiRunOnce <String[]>]
    [-AdminPassword <String>] [-TimeZone <String>] [-AutoLogonCount
    <Int32>] [-Domain <String>] [-Workgroup <String>] [-DomainCredentials 
    <PSCredential>] [-DomainUsername <String>] [-DomainPassword <String>]
    [-ProductKey <String>] [-NamingScheme <String>] [-NamingPrefix 
    <String>] [-Description <String>] [-LicenseMode <LicenseMode>]
    [-LicenseMaxConnections <Int32>] [-WhatIf] [-Confirm] 
    [<CommonParameters>]

The -FullName and -OrgName parameters are required.

Let's start with creating a Linux OS customization specification called LinuxOSSpec, which specifies Linux as the type of operating system and blackmilktea.com as the domain name, using the following command:

PowerCLI C:> New-OSCustomizationSpec -Name LinuxOSSpec `
>> -OSType Linux -Domain blackmilktea.com -Description "Linux spec"

The preceding command will give the following output:

Name                                Description Type          OSType
----                                ----------- ----          ------
LinuxOSSpec                          Linux spec Persistent    Linux

Now, we can clone this OS customization specification with the following command:

PowerCLI C: > New-OSCustomizationSpec -Name LinuxOSSpec2 `
>> -OSCustomizationSpec LinuxOSSpec

The output of the preceding command is as follows:

Name                                Description Type          OSType
----                                ----------- ----          ------
LinuxOSSpec2                         Linux spec Persistent    Linux

Creating a Windows OS customization specification requires some more parameters:

PowerCLI C:> New-OSCustomizationSpec -Name WindowsOSSpec `
>> -OSType Windows `
>> -Domain blackmilktea.com -DomainUsername DomainAdmin `
>> -DomainPassword TopSecret -FullName "Domain administrator" `
>> -OrgName "Black Milk Tea Inc." -Description "Windows Spec"

The output of the preceding command is as follows:

Name                                Description Type          OSType
----                                ----------- ----          ------
WindowsOSSpec                      Windows Spec Persistent    Windows

You can now use an OS customization specification if you create a virtual machine from a template or when you clone a virtual machine. For example, you can use the following command:

PowerCLI C:> New-VM -Name VM5 -Template Windows2016Template `
>> -OSCustomizationSpec WindowsOSSpec -VMHost 192.168.0.133

The output of the preceding command is as follows:

Name                 PowerState Num CPUs MemoryGB
----                 ---------- -------- --------
VM5                  PoweredOff 1        4.000
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.131.178