JDMils_Interact
Enthusiast
Enthusiast

Another code change I had to make was in the calling line:

# Move-VMThin (Get-VM $oTemplateAsVM) (Get-Datastore $TargetDS)
Move-VMThin -VM $($oTemplateAsVM.Name) -Datastore $DatastoreName

 Had to change the -VM & Datastore to strings.

One other thing I need your help with is that, surprisingly to me, you can have more than one template in a vCenter with the SAME name!?

So this line returns multiple objects:

$vmView = Get-View -ViewType VirtualMachine -Filter @{"Name" = "$VM"}

If there's no way to fix this then all I can do is check for $vmView.Count and anything gt 1 will get a message to the user to say something like "Sorry, too many objects returned- do this one manually".

Reply
0 Kudos