SCVMMService crashes on VM creation

I’m using a PowerShell script to create a new VM, based on the code you can get System Center Virtual Machine Manager 2012 SP1 to spit out. I made a change to the script to try to use some unattended settings to set the Windows Registered Owner and Registered Organisation (that end up in HKLM\Software\Microsoft\Windows NT\CurrentVersion\RegisteredOwner and HKLM\Software\Microsoft\Windows NT\CurrentVersion\RegisteredOrganisation respectively).

The code I’m using is the following:

Write-Host "Build new temporary template..."
New-SCVMTemplate -Name $TempTemplateName -Template $Template -HardwareProfile $HardwareProfile -ComputerName $NewVMName -Domain "" -DomainJoinOrganizationalUnit "ou=Build,ou=Servers,dc=rcmtech,dc=co,dc=uk" -DomainJoinCredential $DomainJoinCredential | Out-Null

Write-Host "Get new temporary template object..."
$TempTemplate = Get-SCVMTemplate -VMMServer $SCVMMServer -Name $TempTemplateName

Write-Host "Add autologon credential..."
Set-SCVMTemplate -VMTemplate $TempTemplate -AutoLogonCredential $DomainJoinCredential -AutoLogonCount 100 | Out-Null

Write-Host "Add Local administrator credential..."
$LocalAdministratorCredential = Get-SCRunAsAccount -Name "General Local Admin"
Set-SCVMTemplate -VMTemplate $TempTemplate -LocalAdministratorCredential $LocalAdministratorCredential | Out-Null

# add extra unattended build settings
$Unattend = $TempTemplate.UnattendSettings
# Unattend sections: 6 = oobesystem, 3 = specialize
# Required to make autologon credential work
# Don't waste resources opening these at logon - especially true during build
$unattend.Add(“3/Microsoft-Windows-OutOfBoxExperience/DoNotOpenInitialConfigurationTasksAtLogon”, “true”)
$unattend.Add(“3/Microsoft-Windows-ServerManager-SvrMgrNc/DoNotOpenServerManagerAtLogon”, “true”)
# disable IE ESC or PowerShell build script will be blocked
# Set localisation to UK
$unattend.Add(“6/Microsoft-Windows-International-Core/InputLocale”, “0809:00000809”)
$unattend.Add(“6/Microsoft-Windows-International-Core/SystemLocale”, “en-GB”)
$unattend.Add(“6/Microsoft-Windows-International-Core/UILanguage”, “en-GB”)
$unattend.Add(“6/Microsoft-Windows-International-Core/UserLocale”, “en-GB”)
Set-SCVMTemplate -VMTemplate $TempTemplate -UnattendSettings $Unattend | Out-Null

Write-Host "Build new VM configuration..."
$virtualMachineConfiguration = New-SCVMConfiguration -VMTemplate $TempTemplate -Name $NewVMName

The lines I added were the following, just before the Set-SCVMTemplate line:

# Set Owner info
$unattend.Add("7/Microsoft-Windows-Shell-Setup/RegisteredOrganization", "RCMTech")
$unattend.Add("7/Microsoft-Windows-Shell-Setup/RegisteredOwner", "Robin CM")

But this then caused the System Center Virtual Machine Manager service to crash at the “Customizing virtual machine” step.

The following errors were logged in the VM Manager event log on the VMM server:

Log Name:      VM Manager
Source:        Virtual Machine Manager
Date:          07/08/2013 09:08:18
Event ID:      1
Task Category: None
Level:         Error
Keywords:      Classic
User:          N/A
System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.VirtualManager.WorkloadCreation.UnattendXMLFile.createSetting(UnattendXMLEntryInfo entryInfo, CreateOptions createOption)
   at Microsoft.VirtualManager.WorkloadCreation.UnattendXMLFile.Set(SysPrepEntry entry)
   at Microsoft.VirtualManager.WorkloadCreation.UnattendAnswerFile.GenerateAnswerFile(List`1 overridedSysPrepEntries)
   at Microsoft.VirtualManager.Engine.VmOperations.CustomizeVMSubtask.GenerateAnswerFile()
   at Microsoft.VirtualManager.Engine.VmOperations.CustomizeVMSubtask.RunSubtask()
   at Microsoft.VirtualManager.Engine.TaskRepository.SubtaskBase.Run()
   at Microsoft.VirtualManager.Engine.VmOperations.NewVmFromTemplateSubtask.PostVmCreationCustomize()
   at Microsoft.VirtualManager.Engine.VmOperations.NewVmSubtaskBase.RunNewVmSubtasks()
   at Microsoft.VirtualManager.Engine.VmOperations.NewVmSubtaskBase.RunSubtask()
   at Microsoft.VirtualManager.Engine.VmOperations.NewVmFromTemplateSubtask.RunSubtask()
   at Microsoft.VirtualManager.Engine.TaskRepository.SubtaskBase.Run()
   at Microsoft.VirtualManager.Engine.TaskRepository.Task`1.SubtaskRun(Object state)-2147467261


Log Name:      VM Manager
Source:        Virtual Machine Manager
Date:          07/08/2013 09:08:18
Event ID:      19999
Task Category: None
Level:         Error
Keywords:      Classic
User:          N/A
Description: Virtual Machine Manager (vmmservice:4760) has encountered an error and needed to exit the process. Windows generated an error report with the following parameters: 

Removing the two lines that I added fixed this – but I’m disappointed that the SCVMM Service is so flaky and intolerant of errors.

I did guess at the values, but they seemed correct based on TechNet.

The problem seems to be that I got the numeric section value of 7 from some screenshots I took when documenting settings I used in WSIM from a previous incarnation of my automated build system:
WSIM Components
whereas the actual numbers used in the XML start at zero, not 1. So I changed the two lines to the following:

# Set Owner info
$unattend.Add(“6/Microsoft-Windows-Shell-Setup/RegisteredOrganization”, “RCMTech”)
$unattend.Add(“6/Microsoft-Windows-Shell-Setup/RegisteredOwner”, “Robin CM”)

And now it’s fine.

…Of course, as this is just putting in some static registry values I could also have done this in any number of other ways, but there you go!



This entry was posted in Hyper-V, PowerShell, Windows and tagged , , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.