![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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) |
| | Powershell, WMI and Hyper-V - Oh My Hi guys! I am trying to work out ways to automate the provisioning of virtual machines under hyper-v. If I do the following: $var1 = get-wmiobject -namespace root\virtualization Msvm_VirtualSystemManagementService $createnewvm = $var1.DefineVirtualSystem() …it works fine. So why cant I call the DefineVirtualMachine method in a single gwmi command like this: gwmi -namespace root\virtualization Msvm_VirtualSystemManagementService.DefineVirtualSystem() The detailed help for get-wmiobject seems to suggest it can be done in this way: -------------------------- EXAMPLE 5 -------------------------- C:\PS>(get-wmiobject win32_service -filter "name='alerter'").StopService() This command stops the Alerter service. It calls the StopService method of the win32_service WMI class. Am I missing something? Thanks guys. |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Powershell, WMI and Hyper-V - Oh My Rorschach wrote: Quote: > So why cant I call the DefineVirtualMachine method in a single gwmi command > like this: > > gwmi -namespace root\virtualization > Msvm_VirtualSystemManagementService.DefineVirtualSystem() > > The detailed help for get-wmiobject seems to suggest it can be done in this > way: > > -------------------------- EXAMPLE 5 -------------------------- > > C:\PS>(get-wmiobject win32_service -filter "name='alerter'").StopService() Quote: > Am I missing something? what's inside them before trying to access a member. -- Author, Tech Prosaic blog (http://halr9000.com) Webmaster, Psi (http://psi-im.org) Community Director, PowerShellCommunity.org Co-host, PowerScripting Podcast (http://powerscripting.net) |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Powershell, WMI and Hyper-V - Oh My There is a good series of posts on PowerShell and Hyper-V at http://dungkhoang.spaces.live.com/ -- Richard Siddaway All scripts are supplied "as is" and with no warranty PowerShell MVP Blog: http://richardsiddaway.spaces.live.com/ PowerShell User Group: http://www.get-psuguk.org.uk "Hal Rottenberg" wrote: Quote: > Rorschach wrote: Quote: > > So why cant I call the DefineVirtualMachine method in a single gwmi command > > like this: > > > > gwmi -namespace root\virtualization > > Msvm_VirtualSystemManagementService.DefineVirtualSystem() > > > > The detailed help for get-wmiobject seems to suggest it can be done in this > > way: > > > > -------------------------- EXAMPLE 5 -------------------------- > > > > C:\PS>(get-wmiobject win32_service -filter "name='alerter'").StopService() Quote: > > Am I missing something? > Yup! Look again--you need those parentheses to tell powershell to execute > what's inside them before trying to access a member. > > > -- > Author, Tech Prosaic blog (http://halr9000.com) > Webmaster, Psi (http://psi-im.org) > Community Director, PowerShellCommunity.org > Co-host, PowerScripting Podcast (http://powerscripting.net) > |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Powershell, WMI and Hyper-V - Oh My Rorschach wrote: Quote: > WMI is new to me but I grasp that > a namespace is a collection or grouping of classes, that classes represent > given manageable components and that methods represent practical functions of > a class. methods and properties. Quote: > (get-wmi –namespace\virtualization Msvm_VirtualSystemManagementService). > DefineVirtualSystem() $vmgmt = get-wmi –namespace\virtualization Msvm_VirtualSystemManagementService Quote: > So that gave me a blank virtual machine under Hyper-V... I’m curious as to > the parameters for the DefineVirtualSystem method. powershell. Learn the Get-Member and Get-Command cmdlets. ps > $disks = gwmi Win32_LogicalDisk ps > $disks | Get-Member -MemberType method <snip> ps > $disks | Get-Member chkdsk | format-list TypeName : System.Management.ManagementObject#root\cimv2\Win32_LogicalDisk Name : Chkdsk MemberType : Method Definition : System.Management.ManagementBaseObject Chkdsk(System.Boolean FixErrors, System.Boolean VigorousIndexCheck, System.Boolean SkipFolderCycle, System.Boolean ForceDismount, System.Boolean RecoverBadSectors, System.Boolean OkToRunAtBootUp) Quote: > Is there a simpler way of changing the resource allocation for CPU, RAM > etc? Following this example, I am a bit lost after the $VMSettingData > variable is defined. moment. However, if you grab System Center Virtual Machine Manager 2008 (SCVMM) it comes with cmdlets to do all of this stuff I believe. You can download the beta for free now: http://www.microsoft.com/systemcente...m/default.mspx Quote: > Apologies for my stupidity, I will eventually get to grips with this. The > first few days are always the hardest ![]() bad about not immediately getting it! It is probably worth your time to mess with SCVMM. -- Author, Tech Prosaic blog (http://halr9000.com) Webmaster, Psi (http://psi-im.org) Community Director, PowerShellCommunity.org Co-host, PowerScripting Podcast (http://powerscripting.net) |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Hyper-v and Powershell | Virtual Server | |||
| 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 Leaders Join Forces and offer a pre-release version of PowerShell for 50% off the retail value | PowerShell | |||