Please Help to shutdown VM according to its Core

Oct 13, 2009 at 9:26 PM
Edited Nov 4, 2009 at 11:41 PM

First of all Thank you for great hyperv.ps1

I need to create ps1 or bat which will find on local host a VM with 2 cores, shut it down, change Cores from 2 to 4 and start it.

Here what I have so far:

powershell.exe "& {. 'C:\prod\hyperv.ps1';shutdown-VM %%}"
sleep 50
powershell.exe "& {. 'C:\prod\hyperv.ps1';Set-VMCPUCount %% 4 -Server "."}"
powershell.exe "& {. 'C:\prod\hyperv.ps1';start-VM %%}"

the only one thing left is figure out how to determine name with 2 cores

 

Any help will be appreciated.

Thanks,

Andrew

Coordinator
Nov 3, 2009 at 12:17 PM

Get-vm | where { (Get-vmCpuCount $_ ).VirtualQuanitity -eq 2 } |  foreach-object { Stop-vm $_  ; set-vmCpuCount -vm $_ -cpucount 4 ; start-vm $_ }

 

should do it.

 

 

Nov 4, 2009 at 11:40 PM

nope, doesnt work :(

Does nothing

Coordinator
Nov 12, 2009 at 2:58 PM

I haven't been back to check that it works with the older .ps1 version. Certainly works on the new version.  I'll try the old version later.