More WMI and Hyper-V Woes, any help appreciated


i've been playing wmi provider hyper-v more today, after reading  of excellent examples @ http://dungkhoang.spaces.live.com/default.aspx?mkt=en-us&partner=live.spaces. wmi new me grasp that 
a namespace collection or grouping of classes, classes represent given manageable components , methods represent practical functions of class.


so using of dung's examples worked out calling definevirtualsystem method can create new vm:

 

(get-wmi –namespace\virtualization msvm_virtualsystemmanagementservice). definevirtualsystem()


so gave me blank virtual machine under hyper-v... i’m curious parameters definevirtualsystem method. having read here seem can use resourcesettingdata parameter define settings when calling definevirtualsystem, having read paragraph:

 

resourcesettingdata

an optional parameter contains number of embedded instances of cim_resourceallocationsettingdata class (or derived classes thereof). these instances describe virtual resources of virtual computer system. default set of devices created virtual system regardless of whether parameter set. example, processor , memory automatically created , configured default values.


…i little confused

 

here themsdn link explanation regarding definevirtualsystem method - http://msdn.microsoft.com/en-us/library/cc136786(vs.85).aspx

 

i’m trying head around following example of how change ram allocation in defined vm:

 

$vm_service = get-wmiobject -namespace root\virtualization msvm_virtualsystemmanagementservice

 

$newvm = gwmi -namespace root\virtualization msvm_computersystem | {$_.elementname -like "new virtual machine"}

 

## first need locate active settings of virtual machine

 

$newvm = gwmi -namespace root\virtualization msvm_computersystem | {$_.elementname -like "new virtual machine"}

 

$vmsettingdata = get-wmiobject -namespace root\virtualization msvm_virtualsystemsettingdata -filter "systemname = `'$($newvm.name)`'"

 

## find resources allocated vm. 1 particular resource virtual memory resource

 

$vmem = gwmi -namespace root\virtualization msvm_virtualsystemsettingdatacomponent | {$_.partcomponent -like "*memory*"}

 

## find instance of msvm_memorysettingdata matches $vmem.partcomponent

 

$mem =  gwmi -namespace root\virtualization msvm_memorysettingdata | {$_.__path -like $($vmem.partcomponent) }

 

## modify quantity of ram

 

$mem.virtualquantity = [string]1024

$mem.reservation = [string]1024

$mem.limit = [string]1024

 

## commit changes

 

$vm_service.modifyvirtualsystemresources($newvm.__path, $mem.psbase.gettext(1))

 

is there simpler way of changing resource allocation cpu, ram etc?  following example, bit lost after $vmsettingdata variable defined.  i not quite sure achived clause, {$_.partcomponent -like "*memory*"} , {$_.__path -like $($vmem.partcomponent) }

 

apologies stupidity, grips this. first few days hardest smile

i'd suggest starting here: http://blogs.msdn.com/virtual_pc_guy/archive/2008/05/28/scripting-vm-creation-with-hyper-v.aspx


this posting provided "as is" no warranties, , confers no rights.


Windows Server  >  Hyper-V



Comments

Popular posts from this blog

2008 Windows Deployment Server Properties Error

Can no longer user MS Update - Files required to use Microsoft Update are no longer registered

How do a find data in one file, search for it in another file and if not found, write a custom message to another file