VMware Cloud Community
filjo2409
Enthusiast
Enthusiast

Using Invoke-VMScript cmdlet in vCloud environment - Converting CIVM to VM object

So I'm trying to use the Invoke-VMScript cmdlet to do some bash scripting on my VMs. The problem is that I'm working in a vCloud environment and not vSphere. This poses an issue since the Invoke-VMScript cmdlet only accepts VM object as a parameter and the only thing I have close to it is CIVM.

So, is there a way to use Invoke-VMScript cmdlet in a vCloud and is it possible to to convert CIVM to VM in order to pass it to the Invoke-VMScript cmdlet?

Reply
0 Kudos
9 Replies
LucD
Leadership
Leadership

Did you try

$vm = $civm | Get-VM


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

Reply
0 Kudos
filjo2409
Enthusiast
Enthusiast

I have tried that, it returns an empty value. My guess its because maybe Get-VM isn't working on a vCloud env.

Reply
0 Kudos
filjo2409
Enthusiast
Enthusiast

I have tried that, it returns an empty value. My guess its because maybe Get-VM isn't working on a vCloud env.

Reply
0 Kudos
LucD
Leadership
Leadership

Does $civm.Name contains the DisplayName of the VM?
If yes, you could try a Get-VM -Name $civm.Name


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

Reply
0 Kudos
filjo2409
Enthusiast
Enthusiast

Thing is I cannot use Get-VM at all since I'm not working within a vSphere environment but vCloud.

For example:

I'm using 

Connect-CIServer cmdlet to connect to my server as suppose to using Connect-VIServer.
 
And so, when I try using the syntax for vSphere I get the error from the attachment saying I'm not connected to the server. But I am, just not the appropriate environment for the syntax.
Reply
0 Kudos
LucD
Leadership
Leadership

I see, then I'm afraid that the answer to your original question is "no, that is not possible".

The Invoke-VMScript cmdlet is based on the GuestOperations APIs, and for those you need an active vCenter connection.


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

Reply
0 Kudos
filjo2409
Enthusiast
Enthusiast

I see. And I suppose there is no alternative to the Invoke-VMScript cmdlet for vCloud? Any workarounds?

Reply
0 Kudos
LucD
Leadership
Leadership

Not that I know of I'm afraid.


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

Reply
0 Kudos
filjo2409
Enthusiast
Enthusiast

Ok, thanks for your time.

Reply
0 Kudos