使用PowerCLI批量修改虚拟机的磁盘超时参数(Disk Timeout)

$VMs = Get-Cluster “Cluster” | Get-VM | Where { $_.PowerState -eq “PoweredOn” }
ForEach ($VM in $VMs) {
   $reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey(‘LocalMachine’, $VM.Guest.Hostname)
   Write-Host “Registry Value Before: “$VM.Guest.HostName “-” $reg.OpenSubKey(“SYSTEMCurrentControlSetServicesDisk”).GetValue(“TimeoutValue”)
 
   $regKey= $reg.OpenSubKey(“SYSTEMCurrentControlSetServicesDisk”,$true)
   $regkey.SetValue(‘TimeoutValue’,190,’DWord’)
 
   Write-Host “Registry Value After:  “$VM.Guest.HostName “-” $reg.OpenSubKey(“SYSTEMCurrentControlSetServicesDisk”).GetValue(“TimeoutValue”)
}

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注