![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Hyper-v and Powershell Dear All, I hope this is the right group and apologies if it isn't. I need to create a number of Hyper-V Virtual Machines and I thought I would script it with Powershell. I thought that would be quicker than just creating them by hand. Ah well I'll know better next time. Anyway, I now have a script but only works once. When now VMs exist the script works but when I try to create a second or third VM it fails in various places. The code in each of the places is pretty much the same so I'll only quote a snippet. Here is the code to allocate the number or processors. $VProc = gwmi -namespace root\virtualization Msvm_VirtualSystemSettingDataComponent | where {$_.PartComponent -like "*processor*"} $Proc = gwmi -namespace root\virtualization Msvm_ProcessorSettingData | where {$_.__PATH -like $($VProc.PartComponent) } $Proc.VirtualQuantity = $NProcs $Result = $VSManagementService.ModifyVirtualSystemResources($NewVM_PATH, $Proc.psbase.getText(1)) When I create the first VM it is fine but when I create a second one I get: Property 'VirtualQuantity' cannot be found on this object; make sure it exists and is settable. At E:\Shared\Hyper-V\Hyper-V Clone.ps1:264 char:7 + $Proc.V <<<< irtualQuantity = $NProcs You cannot call a method on a null-valued expression. At E:\Shared\Hyper-V\Hyper-V Clone.ps1:265 char:94 + $Result = $VSManagementService.ModifyVirtualSystemResources($NewVM_PATH, $Pro c.psbase.getText( <<<< 1)) This has me beaten I'm afraid. Any advice will be appreciated. -- Best wishes... Colin Bruce Coventry University |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Hyper-v and Powershell Have you seen this: http://www.codeplex.com/PSHyperv "Colin Bruce" <ccx004@xxxxxx-THIS-coventry.ac.uk.AND-THIS> wrote in message news:B2EE4D95-A865-42C1-BD1D-DD1899627646@xxxxxx Quote: > Dear All, > > I hope this is the right group and apologies if it isn't. > > I need to create a number of Hyper-V Virtual Machines and I thought I > would > script it with Powershell. I thought that would be quicker than just > creating > them by hand. Ah well I'll know better next time. Anyway, I now have a > script > but only works once. When now VMs exist the script works but when I try to > create a second or third VM it fails in various places. The code in each > of > the places is pretty much the same so I'll only quote a snippet. Here is > the > code to allocate the number or processors. > > $VProc = gwmi -namespace root\virtualization > Msvm_VirtualSystemSettingDataComponent | where {$_.PartComponent -like > "*processor*"} > $Proc = gwmi -namespace root\virtualization Msvm_ProcessorSettingData | > where {$_.__PATH -like $($VProc.PartComponent) } > $Proc.VirtualQuantity = $NProcs > $Result = $VSManagementService.ModifyVirtualSystemResources($NewVM_PATH, > $Proc.psbase.getText(1)) > > When I create the first VM it is fine but when I create a second one I > get: > > Property 'VirtualQuantity' cannot be found on this object; make sure it > exists > and is settable. > At E:\Shared\Hyper-V\Hyper-V Clone.ps1:264 char:7 > + $Proc.V <<<< irtualQuantity = $NProcs > You cannot call a method on a null-valued expression. > At E:\Shared\Hyper-V\Hyper-V Clone.ps1:265 char:94 > + $Result = $VSManagementService.ModifyVirtualSystemResources($NewVM_PATH, > $Pro > c.psbase.getText( <<<< 1)) > > This has me beaten I'm afraid. > > Any advice will be appreciated. > -- > Best wishes... > Colin Bruce > Coventry University |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Hyper-V vs Full Win2008 Hyper-V | Virtual Server | |||
| Hyper-V standalone vs Hyper-V windows 2008 Core | Virtual Server | |||
| Cannot manage an Hyper-V on Core from a full installed W2K8 with Hyper-V... | Virtual Server | |||
| Powershell, WMI and Hyper-V - Oh My | PowerShell | |||
| PowerShell Leaders Join Forces and offer a pre-release version of PowerShell for 50% off the retail value | PowerShell | |||