@@ -392,8 +392,6 @@ pub struct HyperVSetVMFirmwareArgs<'a> {
392392 /// Specifies the ID of virtual machines for which you want to modify the
393393 /// firmware configuration.
394394 pub vmid : & ' a Guid ,
395- /// Specifies whether to enable secure boot for the virtual machine.
396- pub secure_boot_enabled : bool ,
397395 /// Specifies the name of the secure boot template. If secure boot is
398396 /// enabled, you must have a valid secure boot template for the guest
399397 /// operating system to start.
@@ -402,32 +400,24 @@ pub struct HyperVSetVMFirmwareArgs<'a> {
402400
403401/// Runs Set-VMFirmware with the given arguments.
404402pub fn run_set_vm_firmware ( args : HyperVSetVMFirmwareArgs < ' _ > ) -> anyhow:: Result < ( ) > {
405- // Determine the boot state based on whether secure boot is enabled
406- let boot_state = if args. secure_boot_enabled {
407- ps:: RawVal :: new ( "On" )
408- } else {
409- ps:: RawVal :: new ( "Off" )
410- } ;
411-
412- // Build the PowerShell command
413403 let mut builder = PowerShellBuilder :: new ( )
414404 . cmdlet ( "Get-VM" )
415405 . arg ( "Id" , args. vmid )
416- . pipeline ( )
417- . cmdlet ( "Set-VMFirmware" )
418- . arg ( "EnableSecureBoot" , boot_state) ;
406+ . pipeline ( ) ;
419407
420- // Add the secure boot template if specified
421- if let Some ( template) = args. secure_boot_template {
422- builder = builder. arg ( "SecureBootTemplate" , template) ;
423- }
408+ builder = match args. secure_boot_template {
409+ None => builder
410+ . cmdlet ( "Set-VMFirmware" )
411+ . arg ( "EnableSecureBoot" , ps:: RawVal :: new ( "Off" ) )
412+ . finish ( ) ,
413+ Some ( template) => builder
414+ . cmdlet ( "Set-VMFirmware" )
415+ . arg ( "EnableSecureBoot" , ps:: RawVal :: new ( "On" ) )
416+ . arg ( "SecureBootTemplate" , template)
417+ . finish ( ) ,
418+ } ;
424419
425- // Execute the command
426- builder
427- . finish ( )
428- . output ( true )
429- . map ( |_| ( ) )
430- . context ( "set_vm_firmware" )
420+ builder. output ( true ) . map ( |_| ( ) ) . context ( "set_vm_firmware" )
431421}
432422
433423/// Runs Set-VMFirmware with the given arguments.
0 commit comments