VMware Cloud Community
BrennyMcD
Contributor
Contributor

Error when trying to clone machine

I have looked through previous posts, but none seem o mention the issue i am having. I am running the latest PowerCLI v12.3, i am able to create new vm's without any issue by using the new-vm cmdlet, but assoon as i add the switch for -vm for exisitng machine,

New-VM -VM $ClnVMNm -ResourcePool $Resource -Datastore $DSName -Location $LOcation -Name $NewVMNm

i get the following error.

New-VM : 08/06/2021 10:42:09 New-VM
At line:1 char:21
+ ... W10_Base' | New-VM -ResourcePool 'SOSPlantIntegrationSupport' -Datast ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [New-VM], VimException

if i remove the switch -VM $ClnVMNm from the command, it creates a blank vm for me.

 

Any ideas greatly appreciated

Brendan

Reply
0 Kudos
16 Replies
LucD
Leadership
Leadership

You are not showing the complete line that is mentioned in the error.
You are piping something to the New-VM cmdlet.


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

Reply
0 Kudos
BrennyMcD
Contributor
Contributor

How do i get to see the full line, I am using POWERSHELL ISE and that is all i see in the terminl window, is there a log file that i can read to see the full error ?

Reply
0 Kudos
LucD
Leadership
Leadership

I mean the line with the New-VM that you are using.
From the error message it looks like you are piping something to the New-VM cmdlet.
That line from the ISE is what I would like to see.


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

Reply
0 Kudos
BrennyMcD
Contributor
Contributor

New-VM -VM $ClnVMNm -ResourcePool $Resource -Datastore $DSName -Location $Location -Name $NewVMNm

 

is the line I am using.

 

Bren

Reply
0 Kudos
LucD
Leadership
Leadership

That is not what the error message is saying

pipeline.jpg


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

Reply
0 Kudos
BrennyMcD
Contributor
Contributor

I tried it with names alone and got the same result, but here is the snippet i used

$ClnVMNm = "W10_Base"
$Resource = "SOSPlantIntegrationSupport"
$DSName = "SELU3PAR03_SOS_PLANT_INT_00"
$Location = "POD_005"
$NewVMNm = "BrensTest6"


New-VM -VM $ClnVMNm -ResourcePool $Resource -Datastore $DSName -Location $Location -Name $NewVMNm

and this is the error from this .

New-VM : 08/06/2021 13:24:50 New-VM
At line:13 char:1
+ New-VM -VM $ClnVMNm -ResourcePool $Resource -Datastore $DSName -Locat ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [New-VM], VimException
+ FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Comman

 

Reply
0 Kudos
LucD
Leadership
Leadership

Did you try with

New-VM -VM (Get-VM -Name $ClnVMNm) -ResourcePool $Resource -Datastore $DSName -Location $Location -Name $NewVMNm


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

Reply
0 Kudos
BrennyMcD
Contributor
Contributor

A different format from the manual, but i tried what you suggested and got the same

 

New-VM : 08/06/2021 13:46:36 New-VM
At line:13 char:1
+ New-VM -VM (Get-VM -Name $ClnVMNm) -ResourcePool $Resource -Datastore ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [New-VM], VimException
+ FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Comman
ds.NewVM

Reply
0 Kudos
LucD
Leadership
Leadership

Did you stop/start your ISE in the mean time?


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

Reply
0 Kudos
BrennyMcD
Contributor
Contributor

so just to be on the safe side, shutdown ise, rebooted my computer, then i ran it again, got the same error.

 

Bren

Reply
0 Kudos
LucD
Leadership
Leadership

I just tested that exact code on vSphere 7 with PS v5.1 and PS v7, both worked without a problem.

This must be something in your PowerCLI installation or your vSphere environment.


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

Reply
0 Kudos
BrennyMcD
Contributor
Contributor

I have PS5.1 but vsphere is 6.7.  I have a colleague who seems to be able to also use the same script from his machine to the same host i am trying and his works also.  I have tried to uninstall and reinstall powercli, but same issue.  I will try to upgrade pwoersheel as well as a last resort on my machine.

 

Thanks for tryin to help reolve the isssue with me, much appreciated.

 

Bren

Reply
0 Kudos
LucD
Leadership
Leadership

When reinstalling PowerCLI, make sure after removing the PowerCLI folders that they are actually all gone.
Check with

Get-Module -Name VMware* -ListAvailable


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

Reply
0 Kudos
BrennyMcD
Contributor
Contributor

Just an update, i uninstalled the vware modules in PS5.1, rebooted machne, installed PS7.1 and then carried on installing the powercli in ps7.1, was able to create new vm's from scratch as before, but still now joy with cloning. Suggests to me something wrong with my connection to vsphere somehow, just strange that i can create vm's but not clone them, same commend, just one extra switch.

 

Bren

Reply
0 Kudos
LucD
Leadership
Leadership

Did you check you have sufficient rights in vSphere?
Source VM, target folder, resourcepool ...


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

Reply
0 Kudos
BrennyMcD
Contributor
Contributor

so if log into vsphere directly, i can create VM's and clone VM's for everything i am trying to do with powershell. I can do exactly what i am trying to do  with the powershell script, when i am in the vspere enviroment, 

 

Bren

Reply
0 Kudos