You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Get all VMs$vms=Get-VM# Loop through each VMforeach ($vmin$vms) {
# Create the configuration spec$vmConfigSpec=New-Object VMware.Vim.VirtualMachineConfigSpec
$vmConfigSpec.bootOptions=New-Object VMware.Vim.VirtualMachineBootOptions
$vmConfigSpec.bootOptions.EnterBIOSSetup=$true# Apply the configuration$vm.ExtensionData.ReconfigVM($vmConfigSpec)
# Output the VM name for trackingWrite-Host"Configured BIOS setup on boot for VM: $($vm.Name)"
}
How to change the image used
# ISO path$newIsoPath="[netinstall_darz] os/linux/RHEL/9.1/rhel-baseos-9.1-x86_64-dvd.iso"# Get all VMs$vms=Get-VM# Loop through each VMforeach ($vmin$vms) {
# Get the VM's CD/DVD drive$cdDrive=Get-CDDrive-VM $vm# Create a new virtual device config spec for the CD/DVD drive$cdSpec=New-Object VMware.Vim.VirtualDeviceConfigSpec
$cdSpec.Operation= [VMware.Vim.VirtualDeviceConfigSpecOperation]::Edit
$cdSpec.Device=$cdDrive.ExtensionData# Set the new ISO backing$isoBacking=New-Object VMware.Vim.VirtualCdromIsoBackingInfo
$isoBacking.FileName=$newIsoPath$cdSpec.Device.Backing=$isoBacking# Set connectable info$connectInfo=New-Object VMware.Vim.VirtualDeviceConnectInfo
$connectInfo.AllowGuestControl=$true$connectInfo.StartConnected=$true$connectInfo.Connected=$true$cdSpec.Device.Connectable=$connectInfo# Create the VM config spec$vmConfigSpec=New-Object VMware.Vim.VirtualMachineConfigSpec
$vmConfigSpec.DeviceChange=New-Object VMware.Vim.VirtualDeviceConfigSpec[] (1)
$vmConfigSpec.DeviceChange[0] =$cdSpec# Apply the configuration$vm.ExtensionData.ReconfigVM($vmConfigSpec)
# Output the VM name for trackingWrite-Host"Set ISO for VM: $($vm.Name) to $newIsoPath"
}
How to revert all machines to the latest Snapshot?
# Get all VMs$vms=Get-VM# Loop through each VMforeach ($vmin$vms) {
# Get the latest snapshot of the VM$latestSnapshot=$vm|Get-Snapshot|Sort-Object Created -Descending |Select-Object-First 1# Check if the VM has a snapshotif ($latestSnapshot-ne$null) {
# Revert the VM to the latest snapshotSet-VM-VM $vm-Snapshot $latestSnapshot-Confirm:$false# Output the VM name for trackingWrite-Host"Reverted VM: $($vm.Name) to snapshot: $($latestSnapshot.Name)"
} else {
Write-Host"No snapshot found for VM: $($vm.Name)"
}
}