VMware Horizon Community
LarryTech
Contributor
Contributor
Jump to solution

decrease RAM on vsphere 5.5 clients using powershell

hello

I have vsphere clients with 4gb ram deployed and wish to reduce this amount to 1 gb, they are running w8.1

can I do this using the powershell cli software and script?

I can do this one by one by powering down each and then decreasing RAM within the vsphere interface and then powering back on but I need a better and faster way

and if one can do this by using powershell is there a readymade script I can use or edit?

thanks

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
bayupw
Leadership
Leadership
Jump to solution

Hi

With PowerCLI you can use cmdlets Set-VM with parameter MemoryGB something like below:

Get-VM VM1 | Set-VM -MemoryGB 2

or

Get-VM $VMName | Set-VM -MemoryGB $memorysize -Confirm:$false

If you want to power the VM off first, you can do this

Get-VM $VMName | Stop-VM -RunAsync -Confirm:$false

#or

Get-VM $VMName | Shutdown-VMGuest -Confirm:$false

#set memory in GB

Get-VM $VMName | Set-VM -MemoryGB $memorysize -Confirm:$false

#then power it on

Get-VM $VMName | Start-VM -RunAsync -Confirm:$false

References:

vSphere PowerCLI Reference Set-VM: vSphere 5.5 Documentation Center

VMware KB: Managing virtual machines using PowerCLI

Thanks,

Bayu

Bayu Wibowo | VCIX6-DCV/NV
Author of VMware NSX Cookbook http://bit.ly/NSXCookbook
https://github.com/bayupw/PowerNSX-Scripts
https://nz.linkedin.com/in/bayupw | twitter @bayupw

View solution in original post

0 Kudos
2 Replies
bayupw
Leadership
Leadership
Jump to solution

Hi

With PowerCLI you can use cmdlets Set-VM with parameter MemoryGB something like below:

Get-VM VM1 | Set-VM -MemoryGB 2

or

Get-VM $VMName | Set-VM -MemoryGB $memorysize -Confirm:$false

If you want to power the VM off first, you can do this

Get-VM $VMName | Stop-VM -RunAsync -Confirm:$false

#or

Get-VM $VMName | Shutdown-VMGuest -Confirm:$false

#set memory in GB

Get-VM $VMName | Set-VM -MemoryGB $memorysize -Confirm:$false

#then power it on

Get-VM $VMName | Start-VM -RunAsync -Confirm:$false

References:

vSphere PowerCLI Reference Set-VM: vSphere 5.5 Documentation Center

VMware KB: Managing virtual machines using PowerCLI

Thanks,

Bayu

Bayu Wibowo | VCIX6-DCV/NV
Author of VMware NSX Cookbook http://bit.ly/NSXCookbook
https://github.com/bayupw/PowerNSX-Scripts
https://nz.linkedin.com/in/bayupw | twitter @bayupw
0 Kudos
LarryTech
Contributor
Contributor
Jump to solution

thank you very much for the information and the links you provided

I'm going to try this on a few test machines soon

0 Kudos