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:
M. Marsh 2018-06-25 16:48:16 -07:00 committed by GitHub
commit e5a63a674e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 8 deletions

View File

@ -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