Select-String
processing bcdedit
output deve ser independente do idioma.
Meu idioma alemão é produzido:
> bcdedit
Windows-Start-Manager
---------------------
Bezeichner {bootmgr}
device partition=\Device\HarddiskVolume1
description Windows Boot Manager
locale de-DE
inherit {globalsettings}
default {current}
...snip...
Esta versão modificada do seu script:
function GetBootMgrPartitionPath() {
$bootMgrPartitionPath = bcdedit /enum '{bootmgr'} |
Select-String -Pattern '\{bootmgr\}' -context 1|
ForEach-Object { ($_.Context.PostContext.Split('=')[1]) }
if ($bootMgrPartitionPath -eq $null){
throw "Could not get the partition path of the {bootmgr} BCD entry"
}
return $bootMgrPartitionPath
}
retorna isso:
> GetBootMgrPartitionPath
\Device\HarddiskVolume1