VMware Cloud Community
MartinMEdhouse
Contributor
Contributor

The operation for the entity failed when trying to create new VM

Hi,

I'm using PowerCLI 6.0 and I'm connected to vSphere 5.5. When I want to create a new VM from existing VM I'm getting a little bit confusing excpetion.

My cmdlet is:

New-VM -Name MyName -VM $sourceVM -Datastore $myDataStore -VMHost (Get-VMHost)

It returns the following exception:

New-VM The operation for the entity "xxx" failed with the following message: "The operation is not supported on the object."

What I'm doing wrong or is there any incompatibility between PowerCLI 6.0 and vSphere 5.5?

Thanks

Martin

0 Kudos
7 Replies
LucD
Leadership
Leadership

No, these versions work together.

This error is a bit of a catch-all.

Did you already check the vpxd log (vCenter) ?

Sometimes there are more details on what goes wrong to be found in there.


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

0 Kudos
MartinMEdhouse
Contributor
Contributor

I have no access to vSphere server but I used Get-log command to get logs. But there is no vpxd file.

0 Kudos
Pyrochaser
Contributor
Contributor

Get-vmhost by itself will return all hosts and not specify one host to use, which is what this command expects.

If you know a host you wish to build on you could use the below script:


New-VM -Name MyName -VM $sourceVM -Datastore $myDataStore -VMHost $(Get-VMHost "specify host name")


Otherwise you could build an array and select a vmhost from that array by using the below

# This command builds an array of all you host names into the variable $vmh

$vmh = get-vmhost

# This command selects a random host from this array and assigns it to the $vmhost variable

$vmhost = Get-random -inputobject $vmh

# Now build your VM command with the randomly selected host

New-VM -Name MyName -VM $sourceVM -Datastore $myDataStore -VMHost $vmhost

Make sure you are defining a datastore in a similar fashion as well for your $mydatastore variable

Just making a variable built off get-datastore will not work you have to narrow it down to a single store for the operation New-VM to work


$mds = get-datastore

$mydatastore = Get-random -InputObject $mds


Also make sure your $sourceVM is being defined correctly as well. if more than one object is in this variable it will not work. Make sure $sourceVM equals a single VM name.

As you can see below, when I run the command without clearly identifying it in the variable it gives me nearly the same error (Please note my errors will look a bit different because I use PowerGUI to generate and build my scripts). The highlighted text is the command I ran which looks like yours. The text in red in the red box at the bottom is the error. B y defining your host through random selection or by name should make the command work.

PowerGUI_Script_Editor_2016-06-14_08-26-55.png

0 Kudos
MartinMEdhouse
Contributor
Contributor

I've followed your recommendations but I'm still getting the same error.

0 Kudos
Prakas
Enthusiast
Enthusiast

Can you provide the whole script you are trying to run ?

0 Kudos
Pyrochaser
Contributor
Contributor

Came across this in the VMWare KBs about adjusting the Video RAM memory size. Maybe these steps can help?

Creating View desktops causes the vCenter Server error: The operation is not supported on the object...

Also is your host being managed by vCenter? Here is another post about templates and their management by vCenter. Is your source VM a Template? If so it needs to be converted to VM to be a source VM.

ESXi 5.5 Templates

Hope some of these shed some light on your issue.

0 Kudos
Pyrochaser
Contributor
Contributor

I saw your update on the Stack overflow website. Glad you were able to figure out the issue. Your administrator account not having permissions to clone and the script being run at the host level would definitely make certain portions of the New-VM commandlet not function properly. You will be on the fast track to being a PowerCLI guru in no time! Once you get the hang of it, the process of coming up with new scripts is much easier.

In case you decide you want to do more scripting I would HIGHLY recommend PowerGUI (Sponsored by Dell).

It's a free tool that will give you an advanced Powershell ISE interface. The bonus of the software is if you hover over a command it will tell you

all the switches, parameters, and variables you could potentially use. On the right hand of the script window it even populates your variable

information into drop down menus that you can scan through to find out more advanced variables and parameters that you can use to

fine tune your script even more Smiley Happy

Once again congrats on getting the issue solved!

0 Kudos