Private/Get-BCDEntry.ps1
function Get-BCDEntry { 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, $description = "OSDCloud" ) $bcdHashes = @{ UEFI = "$BootVolume\EFI\Microsoft\Boot\BCD" BIOS = "$BootVolume\Boot\BCD" } foreach ($hash in $bcdHashes) { } "============== UEFI ==============" $uefiBCD = bcdedit -store $BootVolume\EFI\Microsoft\Boot\BCD -enum osloader $string = $uefiBCD | Where-Object { $_ -notmatch '^Windows' -and $_ -ne "" } | Out-String $split = $string -split '-------------------------' | Where-Object { $_ -ne "" } # remov first empty element foreach ($entry in $split) { [PSCustomObject]@{ ID = $($entry -match '(?={).*(?<=})' | out-null ; $Matches[0]) Description = $(($entry -split '\n' | Select-String -Pattern 'description') -replace 'description\s+', '') Device = $(($entry -split '\n' | Select-String -Pattern 'device') -replace 'device\s+', '') } } "============== BIOS ==============" $biosBCD = bcdedit -store $BootVolume\Boot\BCD -enum osloader $string = $biosBCD | Where-Object { $_ -notmatch '^Windows' -and $_ -ne "" } | Out-String $split = $string -split '-------------------------' | Where-Object { $_ -ne "" } # remov first empty element foreach ($entry in $split) { [PSCustomObject]@{ ID = $($entry -match '(?={).*(?<=})' | out-null ; $Matches[0]) Description = $(($entry -split '\n' | Select-String -Pattern 'description') -replace 'description\s+', '') Device = $(($entry -split '\n' | Select-String -Pattern 'device') -replace 'device\s+', '') } } } |