Merge pull request #6422 from DanHam/fix-gh-vmsecureboot
Hyper-V: Use Get-Command over Get-Help to check for SecureBootTemplate parameter
This commit is contained in:
commit
e5a63a674e
|
@ -519,8 +519,9 @@ Hyper-V\Set-VMNetworkAdapter -VMName $vmName -MacAddressSpoofing $enableMacSpoof
|
|||
func SetVirtualMachineSecureBoot(vmName string, enableSecureBoot bool, templateName string) error {
|
||||
var script = `
|
||||
param([string]$vmName, [string]$enableSecureBootString, [string]$templateName)
|
||||
$cmdletParameterExists = Get-Help SetVMFirmware -Parameter SecureBootTemplate -ErrorAction SilentlyContinue
|
||||
if ($cmdletParameterExists) {
|
||||
$cmdlet = Get-Command Hyper-V\Set-VMFirmware
|
||||
# The SecureBootTemplate parameter is only available in later versions
|
||||
if ($cmdlet.Parameters.SecureBootTemplate) {
|
||||
Hyper-V\Set-VMFirmware -VMName $vmName -EnableSecureBoot $enableSecureBootString -SecureBootTemplate $templateName
|
||||
} else {
|
||||
Hyper-V\Set-VMFirmware -VMName $vmName -EnableSecureBoot $enableSecureBootString
|
||||
|
|
Loading…
Reference in New Issue