ganapa2000
Hot Shot
Hot Shot

Create a Linux Customization with TimeZone

Hi,

I am trying to add the Timezone customization parameter but I am unable to understand and use from below thread.

Please help!!

My script

Get-OSCustomizationSpec -Name 'MyLPSRHCust' -ErrorAction SilentlyContinue | Remove-OSCustomizationSpec -Confirm:$false
$sCust = @{
Name = 'MyLPSRHCust'
OSType = 'Linux'
Domain = 'mydomain.com'
Type = 'Persistent'
NamingScheme = 'VM'
DnsServer = '192.168.5.5', '192.168.5.6'
DnsSuffix = 'mydomain.com'
}
$Custo = New-OSCustomizationSpec @sCust
$sCustNic = @{
IpMode = 'UseStaticIp'
IpAddress = $freeip
DefaultGateway = '192.168.11.1'
SubnetMask = '255.255.255.0'
}
Get-OSCustomizationSpec $Custo | Get-OSCustomizationNicMapping | Set-OSCustomizationNicMapping @sCustNic

 

From the below article, I see timezone was added, how can i add the timezone to above script ?

https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/About-VM-Customization-Specifications-...

 

$custMgr = Get-View CustomizationSpecManager

$item = New-Object -TypeName VMware.Vim.CustomizationSpecItem

$info = New-Object -TypeName VMware.Vim.CustomizationSpecInfo
$info.Name = 'Test'
$info.type = 'Linux'
$info.Description = 'Test description'

$spec = New-Object -TypeName VMware.Vim.CustomizationSpec

$identity = New-Object -TypeName VMware.Vim.CustomizationLinuxPrep
$identity.HostName = New-Object -TypeName VMware.Vim.CustomizationFixedName
$identity.HostName.Name = 'TestHost'
$identity.Domain = 'test.domain'
$identity.TimeZone = 'Europe/Brussels'
$spec.Identity = $identity

$ip = New-Object -TypeName VMware.Vim.CustomizationGlobalIPSettings
$ip.DnsServerList = '192.168.1.1','192.168.1.2'
$ip.DnsSuffixList = 'test.domain'
$spec.GlobalIPSettings = $ip

$item.Info = $info
$item.Spec = $spec

$custMgr.CreateCustomizationSpec($item)

 

 

 

0 Kudos
1 Reply
LucD
Leadership
Leadership

Like I explained in that thread (see Solved: Re: About VM Customization Specifications Time Zon... - VMware Technology Network VMTN),

the New-OSCustimizationSpec cmdlet is missing the TimeZone parameter for the Linux parameterset.
The alternative is to use the API method, as shown in that same thread.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference