Hi,

I'm trying to use python and the fantastic WMI module to manage Hyper-V virtual 
machine resources and am having problems trying to modify properties of an 
instance to pass back via WMI.

The following code in powershell is what I need to emulate in python:

$vmms = gwmi -namespace root\virtualization Msvm_VirtualSystemManagementService
$hardDisk = gwmi -namespace root\virtualization 
Msvm_ResourceAllocationSettingData -filter  
InstanceID='Microsoft:Definition\\353B3BE8-310C-4CF4-839E-4E1B14616136\\Default'"
$hardDisk.Address = 0
$vmms.AddVirtualSystemResources($vm,@($hardDisk.GetText(1)))

The equivalent python code below produces a COM error "Provider is not capable 
of the attempted operation" when trying to change object properties.

import wmi
c = wmi.WMI(namespace="virtualization", find_classes=False)
VMMS = c.Msvm_VirtualSystemManagementService()[-1]
HD =  
c.Msvm_ResourceAllocationSettingData(InstanceID='Microsoft:Definition\\353B3BE8-310C-4CF4-839E-4E1B14616136\\Default')
HD.Address = 0
VMMS.AddVirtualSystemResources([HD.gettext_(1),], VM)

I am sure that it is something simple and obvious that I am doing incorrectly 
so apologies in advance for my stupidity.
Any help or suggestions will be gratefully received.

Thanks

Matt

Warwickshire Schools Email System

This email and any files transmitted with it are confidential and intended 
solely for the use of the individual or entity to whom they are addressed.  If 
you have received this email in error please forward to: 
postmas...@we-learn.com.

If the content of this email is considered to be inappropriate or offensive 
please report by forwarding to: reportab...@we-learn.com
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to