This one might be an easy one. When you are getting started with learning something maybe an easy one is the best way to start.
So lets look at the API. https://vmware.github.io/vsphere-automation-sdk-rest/vsphere/index.html

I am not sure how /rest/appliance/shutdown translates into com.vmware.appliance.shutdown but it does. Maybe it is just something you have to remember or lookup on txusa.cloud 🙂 In the following weeks I will post one on accounts and there it is even weirder, because /appliance/local-account somehow translates to com.vmware.appliance.local_accounts. Let’s look at reboot first. So when we click on reboot we see that two parameters are needed. reason of type string and delay of type long and there are no response values.

So to reboot our code would look like this. Parameters: 5 minute delay and reason “A reboot just for the fun of it.”
[code language="powershell"]
## Connect to our VCSA first.
$cisConnection = Connect-CisServer -server vcenter.txusa.cloud
## Get the object
$shutdownAPI = Get-CisService -Name "com.vmware.appliance.shutdown"
## And execute the method to reboot.
$shutdownAPI.reboot(5,"A reboot just for the fun of it.")
[/code]
If you look at the API for poweroff it takes the same two parameters. So our code would look like this for power off.
[code language="powershell"]
## Connect to our VCSA first.
$cisConnection = Connect-CisServer -server vcenter.txusa.cloud
## Get the object
$shutdownAPI = Get-CisService -Name "com.vmware.appliance.shutdown"
## And execute the method to power off.
$shutdownAPI.poweroff(5,"Let's call it a day.")
[/code]
If we look at get. Which will give us the state of a pending request we don’t have any parameters but we have response values.

So our code would look like this.
[code language="powershell"]
## Connect to our VCSA first.
$cisConnection = Connect-CisServer -server vcenter.txusa.cloud
## Get the object
$shutdownAPI = Get-CisService -Name "com.vmware.appliance.shutdown"
## And execute the method to get the pending state information.
$shutdownAPI.get()
[/code]
And last but not least we have the code for cancel which has no parameters and no response. So I guess it will cancel whatever pending request there is.
[code language="powershell"]
## Connect to our VCSA first.
$cisConnection = Connect-CisServer -server vcenter.txusa.cloud
## Get the object
$shutdownAPI = Get-CisService -Name "com.vmware.appliance.shutdown"
## And execute the method to cancel.
$shutdownAPI.cancel()
[/code]