update
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
# report current status
|
||||
$AllVMs = Get-VM | Where-Object { $_.ExtensionData.Summary.Config.ManagedBy.Type -ne "placeholderVm" }
|
||||
$WS2022VMs = $AllVMs | Where-Object { $_.ExtensionData.Guest.GuestFullName -like "*2022*" } | Sort-Object Name
|
||||
$WS2022VMs | select Name, @{n = 'EfiSecureBootEnabled'; e = { $_.ExtensionData.Config.BootOptions.EfiSecureBootEnabled } }
|
||||
|
||||
|
||||
|
||||
$VMNames = @"
|
||||
itdaddressprot2.nd.gov
|
||||
itdqlikreptst1.ndcloud.gov
|
||||
itdqlikrepprd1.ndcloud.gov
|
||||
itdexch1.nd.gov
|
||||
itdexch2.nd.gov
|
||||
itdexchtest1.testnd.gov
|
||||
itdexchtest2.testnd.gov
|
||||
"@
|
||||
|
||||
$VMNames = ConvertTo-Array -MultiLineString $VMNames
|
||||
|
||||
# power off VMs
|
||||
ForEach ($VMName in $VMNames) {
|
||||
Get-VM -Name $VMName | Where-Object { $_.ExtensionData.Summary.Config.ManagedBy.Type -ne "placeholderVm" } | Stop-VMGuest -Confirm:$false
|
||||
}
|
||||
|
||||
# wait for all to be powered off
|
||||
Get-VM -Name $VMNames
|
||||
|
||||
# disable secure boot on all of them
|
||||
ForEach ($VMname in $VMNames) {
|
||||
$vm = Get-VM -Name $VMName | Where-Object { $_.ExtensionData.Summary.Config.ManagedBy.Type -ne "placeholderVm" }
|
||||
$spec = New-Object VMware.Vim.VirtualMachineConfigSpec
|
||||
$spec.Firmware = [VMware.Vim.GuestOsDescriptorFirmwareType]::efi
|
||||
$boot = New-Object VMware.Vim.VirtualMachineBootOptions
|
||||
$boot.EfiSecureBootEnabled = $true # false to disable obviously
|
||||
$spec.BootOptions = $boot
|
||||
$vm.ExtensionData.ReconfigVM($spec)
|
||||
}
|
||||
|
||||
# power on
|
||||
ForEach($VMName in $VMNames){
|
||||
Get-VM -Name $VMName | Where-Object { $_.ExtensionData.Summary.Config.ManagedBy.Type -ne "placeholderVm" } | Start-VM
|
||||
}
|
||||
Reference in New Issue
Block a user