davidstamen 09月29日
虚拟机热添加CPU和内存的PowerShell脚本
index_new5.html
../../../zaker_core/zaker_tpl_static/wap/tpl_guoji1.html

 

本文介绍了如何使用PowerShell脚本实现虚拟机的CPU和内存热添加功能,包括开启和关闭热添加的脚本示例。

I had a need to enable CPU and Memory hotadd to many virtual machines prior to a template being updated, doing some research there is no easy way, however there are some functions out there to do it. You can copy and paste each function into a powershell window and then run the associated command.

1Enable-MemHotAdd $ServerName2Disable-MemHotAdd $ServerName3Enable-vCPUHotAdd $ServerName4Disable-vCPUHotAdd $ServerName

Enable Memory HotAdd

1Function Enable-MemHotAdd($vm){2$vmview = Get-vm $vm | Get-View3$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec4$extra = New-Object VMware.Vim.optionvalue5$extra.Key="mem.hotadd"6$extra.Value="true"7$vmConfigSpec.extraconfig += $extra8$vmview.ReconfigVM($vmConfigSpec)9}

Disable Memory HotAdd

1Function Disable-MemHotAdd($vm){2$vmview = Get-VM $vm | Get-View3$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec4$extra = New-Object VMware.Vim.optionvalue5$extra.Key="mem.hotadd"6$extra.Value="false"7$vmConfigSpec.extraconfig += $extra8$vmview.ReconfigVM($vmConfigSpec)9}

Enable CPU HotAdd

1Function Enable-vCpuHotAdd($vm){2$vmview = Get-vm $vm | Get-View3$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec4$extra = New-Object VMware.Vim.optionvalue5$extra.Key="vcpu.hotadd"6$extra.Value="true"7$vmConfigSpec.extraconfig += $extra8$vmview.ReconfigVM($vmConfigSpec)9}

Disable CPU HotAdd

1Function Disable-vCpuHotAdd($vm){2$vmview = Get-vm $vm | Get-View3$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec4$extra = New-Object VMware.Vim.optionvalue5$extra.Key="vcpu.hotadd"6$extra.Value="false"7$vmConfigSpec.extraconfig += $extra8$vmview.ReconfigVM($vmConfigSpec)9}

Notes: Enabling CPU Hotadd disables vNUMA. So enable enable this if its really neccessary in your environment.

KB2040375

Fish AI Reader

Fish AI Reader

AI辅助创作,多种专业模板,深度分析,高质量内容生成。从观点提取到深度思考,FishAI为您提供全方位的创作支持。新版本引入自定义参数,让您的创作更加个性化和精准。

FishAI

FishAI

鱼阅,AI 时代的下一个智能信息助手,助你摆脱信息焦虑

联系邮箱 441953276@qq.com

相关标签

虚拟机 热添加 PowerShell CPU 内存
相关文章