Public/New-BCDDiskBoot.ps1

function New-BCDDiskBoot {
    param (
        [Parameter(Mandatory,HelpMessage="Volume which holds the windows boot manager")]
        [ValidateScript({if ($_ -notmatch '^[a-z]:$') { throw "BootVolume only allows simple volume inputs, like d: or e:" }else { $true }})]
        $BootVolume,
        [Parameter(Mandatory,HelpMessage="Windows directory, which will be added to windows boot manager")]
        [ValidateScript({if ($_ -notmatch '^[a-z]:\Windows$') {throw "WindowsDrive only allows windows directory's, like c:\Windows or e:\windows"}})]
        $WindowsDrive,
        [Parameter(Mandatory)]
        $Description
    )

    $wim = Resolve-Path $WimFile
    $deviceValue = "partition=$($wim.Drive)"
    
    # add entry for uefi
    $result = bcdedit -store $BootVolume\EFI\Microsoft\Boot\BCD -create -d $Description -application osloader
    $guid = ($result -split '{|}')[1]

    bcdedit -store $BootVolume\EFI\Microsoft\Boot\BCD -set "{$guid}" device $deviceValue
    bcdedit -store $BootVolume\EFI\Microsoft\Boot\BCD -set "{$guid}" path \windows\system32\boot\winload.efi
    bcdedit -store $BootVolume\EFI\Microsoft\Boot\BCD -set "{$guid}" locale en-US
    bcdedit -store $BootVolume\EFI\Microsoft\Boot\BCD -set "{$guid}" osdevice $deviceValue
    bcdedit -store $BootVolume\EFI\Microsoft\Boot\BCD -set "{$guid}" systemroot \windows    
    bcdedit -store $BootVolume\EFI\Microsoft\Boot\BCD -set "{$guid}" allowedinmemorysettings 0x15000075
    bcdedit -store $BootVolume\EFI\Microsoft\Boot\BCD -set "{$guid}" isolatedcontext Yes
    bcdedit -store $BootVolume\EFI\Microsoft\Boot\BCD -set "{$guid}" inherit '{bootloadersettings}'
    bcdedit -store $BootVolume\EFI\Microsoft\Boot\BCD -set "{$guid}" nx OptIn
    bcdedit -store $BootVolume\EFI\Microsoft\Boot\BCD -set "{$guid}" hypervisorlaunchtype Auto
    bcdedit -store $BootVolume\EFI\Microsoft\Boot\BCD -displayorder "{$guid}" /addlast
    
    # add entry for bios
    $result = bcdedit -store $BootVolume\Boot\BCD -create -d $Description -application osloader
    $guid = ($result -split '{|}')[1]

    bcdedit -store $BootVolume\Boot\BCD -set "{$guid}" device $deviceValue
    bcdedit -store $BootVolume\Boot\BCD -set "{$guid}" path \windows\system32\boot\winload.exe
    bcdedit -store $BootVolume\Boot\BCD -set "{$guid}" locale en-US
    bcdedit -store $BootVolume\Boot\BCD -set "{$guid}" osdevice $deviceValue
    bcdedit -store $BootVolume\Boot\BCD -set "{$guid}" systemroot \windows
    bcdedit -store $BootVolume\Boot\BCD -set "{$guid}" allowedinmemorysettings 0x15000075
    bcdedit -store $BootVolume\Boot\BCD -set "{$guid}" isolatedcontext Yes
    bcdedit -store $BootVolume\Boot\BCD -set "{$guid}" inherit '{bootloadersettings}'
    bcdedit -store $BootVolume\Boot\BCD -set "{$guid}" nx OptIn
    bcdedit -store $BootVolume\EFI\Microsoft\Boot\BCD -set "{$guid}" hypervisorlaunchtype Auto
    bcdedit -store $BootVolume\Boot\BCD -displayorder "{$guid}" /addlast
}