VMware Cloud Community
naamancampbell1
Contributor
Contributor

New-VM The object or item referred to could not be found.

Hi all,

I am unable to deploy VMs from Template using a script that previously worked on a VC 4.0 environment.

After setting the OSCustomisationSpec, my script fails at the New-VM cmdlet:

Code:

  # temporary clone of customisation spec
  $os_spec = New-OSCustomizationSpec -Spec $oscs -Type NonPersistent -Name $temp_oscs
  # set IP address & password
  $nic_mapping = Get-OSCustomizationSpec $os_spec | Get-OSCustomizationNicMapping | Set-OSCustomizationNicMapping -IpMode UseStaticIP -IpAddress $vmip -SubnetMask $vmmask -Dns $vmdns -DefaultGateway $vmgw
  $os_spec = Set-OSCustomizationSpec -Spec $os_spec -AdminPassword $passwd
 
  # create VM
  $newvm = New-VM -VMHost $vmhost -Name $vmname -ResourcePool $vmrp -Location $vmfolder -Datastore $vmds -Template $vmtpl -OSCustomizationSpec $os_spec -RunAsync -Description $vmdesc

Error:

[vSphere PowerCLI] C:\Temp\VMware> .\new-vms.ps1
New-VM : 19/08/2011 11:32:05 AM    New-VM    4F6C012F-41D1-4C62-8754-9C8D3F9B6460    The object or item referred to could not be found.
At C:\Temp\VMware\new-vms.ps1:67 char:18
+   $newvm = New-VM <<<<  -VMHost $vmhost -Name $vmname -ResourcePool $vmrp -Location $vmfolder -Datastore $vmds -Template $vmtpl -OSCustomizationSpec $os_spec -RunAsync -Description $vmdesc
    + CategoryInfo          : NotSpecified: (:) [New-VM], ViError
    + FullyQualifiedErrorId : Client20_VmHostServiceImpl_GetCUstomizationSpecItem_ViError,VMware.VimAutomation.Commands.NewVM

PowerCLI Version: VMware vSphere PowerCLI 4.0 U1 build 208462

I have verified the variables are valid and I have cross-checked the required arguments in the PowerCLI help..

Please help identify what I need to fix in the New-VM command..

Cheers,

Naaman.

Tags (2)
0 Kudos
1 Reply
LucD
Leadership
Leadership

Is there a specific reason why you can't upgrade to PowerCLI 4.1U1 ?

If your vCenter is at least at 4U2, it i supported by the latest PowerCLI build. See the Release Notes.


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

0 Kudos