From 475e79a2510196e967cf739549537b3e53ea6ea6 Mon Sep 17 00:00:00 2001 From: Simon Hulme Date: Mon, 25 Jun 2018 14:13:43 +0100 Subject: [PATCH] Fixed SecureBootTemplate not being passed through to PS cmdlet Added check for SecureBootTemplate parameter for Server 2012 and below Corrected enableSecureBootString usage --- common/powershell/hyperv/hyperv.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/common/powershell/hyperv/hyperv.go b/common/powershell/hyperv/hyperv.go index 392984e3f..5b6501abe 100644 --- a/common/powershell/hyperv/hyperv.go +++ b/common/powershell/hyperv/hyperv.go @@ -518,8 +518,13 @@ Hyper-V\Set-VMNetworkAdapter -VMName $vmName -MacAddressSpoofing $enableMacSpoof func SetVirtualMachineSecureBoot(vmName string, enableSecureBoot bool, templateName string) error { var script = ` -param([string]$vmName, $enableSecureBoot) -Hyper-V\Set-VMFirmware -VMName $vmName -EnableSecureBoot $enableSecureBoot +param([string]$vmName, [string]$enableSecureBootString, [string]$templateName) +$cmdletParameterExists = Get-Help SetVMFirmware -Parameter SecureBootTemplate -ErrorAction SilentlyContinue +if ($cmdletParameterExists) { + Hyper-V\Set-VMFirmware -VMName $vmName -EnableSecureBoot $enableSecureBootString -SecureBootTemplate $templateName +} else { + Hyper-V\Set-VMFirmware -VMName $vmName -EnableSecureBoot $enableSecureBootString +} ` var ps powershell.PowerShellCmd