title: How to query VMs in Azure powerstate using tags
body: <p>I have a script that deallocates all VMs in the subscription based on the tags assigned - off hours and start them back up the next day using Jenkins. I want to be able to query these VMs based on the state (Running/Stopped(deallocated) and output it to a file.</p>
  
  <p>Startup command - <code>az vm start --ids $(az resource list --tag Restart=${TAG_RESTART} --query "[?type=='Microsoft.Compute/virtualMachines'].id" -o table)</code></p>
  
  <p>Query command -
  <code>az resource list --tag Restart=yes --query "[].{Name:name,Group:resourceGroup,Location:location}" -o table</code></p>
  
  <p>This command returns output (Name, RG and location). I want it to also show the powerstate and possibly OS type once the restart script is complete. If it is also possible to export the output to a spreadsheet.</p>