jroeser637
Contributor
Contributor

Put a VM in maintenance mode via PowerCLI (NOT a host)

I have to be missing something here. I've been googling for the past hour and I cannot seem to find a single thing to put a virtual machine in maintenance mode via CLI. Sure, I see something to put a host in maintenance mode, and I see plenty of things to start and stop a VM, yet for some reason I can't find anything to put the VM itself in maintenance mode.

In particular, I want to put a specific virtual machine from a linked-clone pool into maintenance mode. Would anyone have any references/ideas for me to use to accomplish this? I appreciate any help!

0 Kudos
4 Replies
jpsider
Expert
Expert

Maybe it's my ignorance, but I don't think this is a vSphere native thing.

Are you using a VDI application? or are you talking just a normal linked clone chilling in a vCenter?

0 Kudos
jroeser637
Contributor
Contributor

Hmmm, I'm a bit new myself to vpshere, so I'll explain the best I can. It might be a VDI application - not sure. What I can say is that we have several pools set up as linked-clones. I know I can use PowerCLI to connect to VCenter, and then use Get-VM to get a list of all the virtual machines on that VCenter. However, I'm not sure how to choose any machines among that list and put it in maintenance mode through CLI.

The virtual machine I am talking to is in a linked-clone pool...not sure if that answers your question!

0 Kudos
LucD
Leadership
Leadership

That functionality should be available in the Vmware.VimAutomation.HorizonView module.

As Alan explained in Getting started with PowerCLI 6.5 and Horizon View, you have through that module access to the complete Horizon View API.

At first sight, and I haven't tried or tested this yet, it looks like the Desktop_Update method might do this.

I suspect that it's a matter of setting the Enabled property to $false.

But I haven't tried that yet, a weekend project :smileygrin:


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

0 Kudos
jasonkyzer_vmwa
Contributor
Contributor

I cannot get this functionality to work:

```$dh=new-object vmware.hv.machineservice

$hvm=get-hvmachine -machinename pleaseputmeintomaintenancemode

$hvm.managedmachinedata.inmaintenancemode="True"

$mm=get-mapentry managedMachineData $hvm.managedmachinedata

$dh.machine_update($api,$hvm.id,$mm)

Exception calling "Machine_Update" with "3" argument(s): "ExceptionType : VMware.Hv.InvalidArgument

ErrorMessage : Cannot update member with read-only fields.

ParameterName : managedMachineData"```

How else are we supposed to put a host into maintenance mode? I can't find this anywhere else in the API documentation:

https://vdc-repo.vmware.com/vmwb-repository/dcr-public/f004a27f-6843-4efb-9177-fa2e04fda984/5db23088...

0 Kudos