Tags
First post in months. Hopefully I’ll have more to post on in the next few weeks. Onto more pressing issues…
“The N Series VMware ESX Host Utilities” have a couple of ISOs that have scripts for tweaking the guest OS disk timeouts.
From the IBM Redbook IBM System Storage N series and VMware vSphere Storage Best Practices:
This is a job for PowerCLI. Inspired from Jase’s script.
Considerations for Linux: Use an account that can do passwordless sudo (or root- you don’t have to have root SSH enabled for Invoke-VMscript).
# Requires VMware Tools to be installed on each guest.
$winisoName = "[datastore] path/to/windows_gos_timeout.iso"
$linisoName = "[datastore] path/to/linux_gos_timeout.iso"
# Get Windows Guest Credentials
Write-Host "Enter Windows Credentials"
$wincred = Get-Credential
# Get Linux Guest Credentials
Write-Host "Enter Linux Credentials"
$lincred = Get-Credential
# Get ESX Host Creds
Write-Host "Enter ESX Credentials"
$esxcred = Get-Credential
# Get ALL VMs
$vms = Get-VM
foreach($vms as $vm){
$driveName = "CD/DVD Drive 1"
$vm = $vm | Get-View
$dev = $vm.Config.Hardware.Device | where {$_.DeviceInfo.Label -eq $driveName}
$spec = New-Object VMware.Vim.VirtualMachineConfigSpec
$spec.deviceChange = New-Object VMware.Vim.VirtualDeviceConfigSpec[] (1)
$spec.deviceChange[0] = New-Object VMware.Vim.VirtualDeviceConfigSpec
$spec.deviceChange[0].operation = "edit"
$spec.deviceChange[0].device = $dev
$spec.deviceChange[0].device.backing = New-Object VMware.Vim.VirtualCdromIsoBackingInfo
$spec.deviceChange[0].device.backing.fileName = $isoName
$vm.ReconfigVM_Task($spec)
$winscript = "regedit /s windows_gos_timeout.reg"
$linscript = "sudo /media/cdrom/linux_gos_timeout-install.sh"
if($vm.Guest.OSFullName -match "Microsoft") {
Invoke-VMScript -HostCredentials $esxcred -GuestCredentials -ScriptText $winscript
}
else if($vm.Guest.OSFullName -match "Linux") {
Invoke-VMScript -HostCredentials $esxcred -GuestCredentials -ScriptText $linscript
}
}
Back to work.
Advertisement
