Trouble with GetObject / CreateObject

Post Reply
byron.hopp
Posts: 388
Joined: Sun Nov 06, 2005 3:55 pm
Location: Southern California, USA
Contact:

Trouble with GetObject / CreateObject

Post 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 ...
Thanks,
Byron Hopp
Matrix Computer Services
User avatar
Antonio Linares
Site Admin
Posts: 42516
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 75 times
Contact:

Re: Trouble with GetObject / CreateObject

Post by Antonio Linares »

have you tried:

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

Antonio Linares
www.fivetechsoft.com
Post Reply