Hi Everyone
Right now I am trying to make a copy of a Virtual Machine and to customize the settings on the unit for deployment. Right now my code is as follows (Note: I cleaned some of the values before posting public) The return result of this is Invalid Argument. Does anyone know how I can dive deeper into the error and find out what is ultimatly the reason for the issue?
Thanks,
-SysAdmin
Dim CloneSpec As VirtualMachineCloneSpec = New VirtualMachineCloneSpec()
'cloneSpec.Config.CpuFeatureMas()
Dim MyConfig As New VMware.Vim.VirtualMachineConfigSpec
MyConfig.NumCoresPerSocket = 2
MyConfig.NumCPUs = 4
Dim MyLocation As New VMware.Vim.VirtualMachineRelocateSpec
MyLocation.Host = HostMoRef
MyLocation.Pool = PoolMoRef
MyLocation.Datastore = DataStoreMoRef
MyLocation.Transform = VirtualMachineRelocateTransformation.sparse 'Thin Provision
MyLocation.DiskMoveType = VirtualMachineRelocateDiskMoveOptions.createNewChildDiskBacking
Dim MyOptions = New CustomizationWinOptions
MyOptions.ChangeSID = True
MyOptions.DeleteAccounts = False
Dim CustPassword As New CustomizationPassword
CustPassword.Value = "MyPassword1!"
CustPassword.PlainText = True
Dim GUIUnattended As New CustomizationGuiUnattended
GUIUnattended.TimeZone = 85
GUIUnattended.AutoLogon = True
GUIUnattended.AutoLogonCount = 1
Dim CustUserData As New CustomizationUserData
CustUserData.FullName = "Information Systems"
CustUserData.OrgName = "Eisenhower Medical Center"
'Need TimeZone
Dim CustVirtualMachine As New CustomizationVirtualMachineName
CustUserData.ProductId = "XXXXX-XXXXX-XXXXX-XXXXX-XXXXX"
Dim GuiRunOnce As New CustomizationGuiRunOnce
GuiRunOnce.CommandList = New String() {"cmd"}
Dim Iden As New CustomizationIdentification
Iden.JoinDomain = "CNN.COM"
Dim GlobalIPInformation As New CustomizationGlobalIPSettings
GlobalIPInformation.DnsSuffixList = {"CNN.COM"}
'''Attach Classes
CustUserData.ComputerName = CustVirtualMachine
Dim SysPrep As New CustomizationSysprep
SysPrep.UserData = CustUserData
SysPrep.GuiRunOnce = GuiRunOnce
SysPrep.GuiUnattended = GUIUnattended
SysPrep.Identification = Iden
Dim CustSpec As New CustomizationSpec
CustSpec.GlobalIPSettings = GlobalIPInformation
CustSpec.Options = MyOptions
CustSpec.Identity = SysPrep
CloneSpec.Config = MyConfig
CloneSpec.Customization = CustSpec
CloneSpec.Location = MyLocation
'Dim DiskLocater = New VMware.Vim.VirtualMachineRelocateSpecDiskLocator
'Dim DiskBacking = New VMware.Vim.VirtualDeviceBackingInfo
'DiskLocater.DiskBackingInfo = DiskBacking
'cloneSpec.Location.Disk = DiskLocater
CloneSpec.PowerOn = True
Dim MyView As EntityViewBase
Try
'WindowsServer2008r2.CustomizeVM(CloneSpec)
Dim NewServer = WindowsServer2008r2.CloneVM(Folder, NameOfServer, CloneSpec)
MyView = Client.GetView(NewServer, Nothing)
VMS.Add(MyView)
For i = 0 To 100
Debug.WriteLine(i)
Try
MyView.UpdateViewData(Nothing)
Catch ex As Exception
Debug.WriteLine("ViewUpDate " & ex.Message)
End Try
Try
If GetServerStatus(MyView) Then
Exit For
End If
Catch ex As Exception
Debug.WriteLine("GetServerStatus " & ex.Message)
End Try
Threading.Thread.Sleep(2000)
Next
Catch ex As VimException
Select Case ex.Message
Case "The task was canceled by a user."
MsgBox(ex.Message)
Case Else
MsgBox(ex.Message & vbCrLf & ex.MethodFault.ToString)
End Select
End Try
Return MyView