Showing posts with label VM Template. Show all posts
Showing posts with label VM Template. Show all posts

Wednesday, May 8, 2013

VMM 2012 SP1 VM Template - Region Settings revert back to en-US

I thought I would share a common problem that is experienced when configuring Regional Settings on a VM template.

Here is the scenario:
You build your VM with your required OS and make the required customisations for your environment. In most cases (unless you are in the US) this would require changing the Regional Settings. Once you are happy you run the sysprep oobe - generalize and shutdown the VM ready to be moved to the library.

You generate the VMM template from the VM in your library. You run your first test a realise that all the Regional setting have been changed back to English US.

During the above process the regional settings is reverted back to 'en-US'. This functionality is acknowledged in this MS KB article: http://support.microsoft.com/kb/2709539

To configure the proper regional settings for your template you can run a number of PowerShell cmdlets that will update the unattend settings (specifically oobeSystem/Microsoft-Windows-International-Core/UserLocale).

For Australia I generally need to configure the User Locale to 'en-AU' (English-Australia) and the keyboard to 'en-AU' also.

To do this I run the following PowerShell cmdlets (no need to change SystemLocale or UILanguage for Australia region settings):

$template = Get-SCVMtemplate | where {$_.Name -eq "Template - Windows Server 2008 R2 SP1 Enterprise"}
$settings = $template.UnattendSettings;
$settings.add("oobeSystem/Microsoft-Windows-International-Core/UserLocale","en-AU");
$settings.add("oobeSystem/Microsoft-Windows-International-Core/SystemLocale","en-US");
$settings.add("oobeSystem/Microsoft-Windows-International-Core/UILanguage","en-US");
$settings.add("oobeSystem/Microsoft-Windows-International-Core/InputLocale","0c09:00000409");
Set-SCVMTemplate -VMTemplate $template -UnattendSettings $settings



The above PowerShell commands can be modified for your region.

VMM VM Template - AutoLogonCount and AutoLogonCredential for RunOnce

Recently I created a VM template in VMM 2012 SP1 for a customer. A number customization scripts were created and added to RunOnce. The customer wanted the VM template to automatically logon with the local Admin account so all the RunOnce scripts would run automatically.

This is a pretty standard request and when configuring any unattend Windows install this is generally achieved by modifying the unnattend.xml file. However in VMM the Set-SCVMTemplate PowerShell cmdlet can be leveraged to configure this setting.

The 'Get-SCVMTemplate' cmdlet will show the current AutoLogon configuration. The AutoLogonCount and AutoLogonCredentialproperties must both be configured to achieve the Auto Logon functionality:

Get-SCVMTemplate -Name "VM Template Name"

When using AutoLogon in your VM Template it is also important to have a VMM 'Run As' account configured that has the local Admin credentials stored. Once the local Admin 'Run As' account is created, add it to the VM Template OS Properties for the local admin account.

The following PowerShell cmdlets can be used to configure AutoLogonCount and AutoLogonCredential properties:

#Get Template by name
($template = Get-SCVMtemplate | where {$_.Name -eq "VM Template Name"}) | fl Name, OperatingSystem, VirtualizationPlatform


#Get local admin account
($raa = Get-SCRunAsAccount -Name "VM Local Admin Run As") | fl Name, Username, Domain


#Set auto logon
(Set-SCVMTemplate -VMTemplate $template -AutoLogonCredential $raa -AutoLogonCount 1) | fl Name, AutoLogonCredential, AutoLogonCount



By using Run As account for the local admin account for the OS Properties and the AutoLogonCredential this allows the local admin account to be changed without needing to rerun the above PowerShell scripts.

Happy Templating!