Page 1 of 1

Trouble with GetObject / CreateObject

Posted: Fri Aug 20, 2021 7:33 pm
by byron.hopp
All,

I am using some code I found on the web to reset a VM on Hyper-V.

VBScript:
Set sService = GetObject("winmgmts:\\.\root\virtualization")

FWH:
oWinMgmt := CreateObject("winmgmts:\\.\root\virtualization")
oWinMgmt := GetActiveObject("winmgmts:\\.\root\virtualization")
oWinMgmt := Win_OleGetActiveObject("winmgmts:\\.\root\virtualization")

Also tried (based on a post from 2007):
oWinMgmt := CreateObject("winmgmts:")

Everything I have tried:
Valtype( oWinMgmt ) == "U"

I am running this on the Server that hosts the VM systems.

I can run a powershell command and get this accomplished:

Reset-VM -Name "Windows 10_04_New" -Force

Anyone familiar with this?

Thanks,
Byron ...

Re: Trouble with GetObject / CreateObject

Posted: Fri Aug 20, 2021 9:12 pm
by Antonio Linares
have you tried:

hb_Run( "Reset-VM -Name "Windows 10_04_New" -Force" )