We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8376aa9 commit cac5d92Copy full SHA for cac5d92
extensions/HyperV/hyperv.py
@@ -212,7 +212,14 @@ def status(self):
212
213
def statuses(self):
214
command = 'Get-VM | Select-Object Name, State | ConvertTo-Json'
215
- vms = json.loads(self.run_ps(command))
+ output = self.run_ps(command)
216
+ if not output or output.strip() in ("", "null"):
217
+ vms = []
218
+ else:
219
+ try:
220
+ vms = json.loads(output)
221
+ except json.JSONDecodeError:
222
+ fail("Failed to parse VM status output: " + output)
223
power_state = {}
224
if isinstance(vms, dict):
225
vms = [vms]
0 commit comments