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 {
|
func SetVirtualMachineSecureBoot(vmName string, enableSecureBoot bool, templateName string) error {
|
||||||
var script = `
|
var script = `
|
||||||
param([string]$vmName, [string]$enableSecureBootString, [string]$templateName)
|
param([string]$vmName, [string]$enableSecureBootString, [string]$templateName)
|
||||||
$cmdletParameterExists = Get-Help SetVMFirmware -Parameter SecureBootTemplate -ErrorAction SilentlyContinue
|
$cmdlet = Get-Command Hyper-V\Set-VMFirmware
|
||||||
if ($cmdletParameterExists) {
|
# The SecureBootTemplate parameter is only available in later versions
|
||||||
|
if ($cmdlet.Parameters.SecureBootTemplate) {
|
||||||
Hyper-V\Set-VMFirmware -VMName $vmName -EnableSecureBoot $enableSecureBootString -SecureBootTemplate $templateName
|
Hyper-V\Set-VMFirmware -VMName $vmName -EnableSecureBoot $enableSecureBootString -SecureBootTemplate $templateName
|
||||||
} else {
|
} else {
|
||||||
Hyper-V\Set-VMFirmware -VMName $vmName -EnableSecureBoot $enableSecureBootString
|
Hyper-V\Set-VMFirmware -VMName $vmName -EnableSecureBoot $enableSecureBootString
|
||||||
|
|
Loading…
Reference in New Issue