My Cloud Journey

VMware Virtualization

Secure Boot

Function Get-SecureBoot {
<#
Get-VM -Name Windows10 | Get-SecureBoot
#>
param(
[Parameter(
Mandatory=$true,
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true)
]
[VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl]$Vm
)
$secureBootSetting = if ($vm.ExtensionData.Config.BootOptions.EfiSecureBootEnabled) { “enabled” } else { “disabled” }
Write-Host “Secure Boot is” $secureBootSetting
}
Function Set-SecureBoot {
<#
#>
param(
[Parameter(
Mandatory=$true,
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true)
]
[VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl]$Vm,
[Switch]$Enabled,
[Switch]$Disabled
)
if($Enabled) {
$secureBootSetting = $true
$reconfigMessage = “Enabling Secure Boot for $Vm”
}
if($Disabled) {
$secureBootSetting = $false
$reconfigMessage = “Disabling Secure Boot for $Vm”
}
$spec = New-Object VMware.Vim.VirtualMachineConfigSpec
$bootOptions = New-Object VMware.Vim.VirtualMachineBootOptions
$bootOptions.EfiSecureBootEnabled = $secureBootSetting
$spec.BootOptions = $bootOptions

Write-Host “`n$reconfigMessage …”
$task = $vm.ExtensionData.ReconfigVM_Task($spec)
$task1 = Get-Task -Id (“Task-$($task.value)”)
$task1 | Wait-Task | Out-Null
}

Design a site like this with WordPress.com
Get started