# Based on: http://stackoverflow.com/questions/16903460/bcdedit-bcdstore-and-powershell # Uses System.Management.ManagementObjects, documented: https://msdn.microsoft.com/en-us/library/system.management # BCD Objects inherit the properties defined by the BCD WMI Provider Classes: https://msdn.microsoft.com/en-us/library/windows/desktop/aa362675 param ( # CLI accepts the following parameters: [string]$Hostname = '.', # Localhost by default. [int]$bcdStoreType = 0x10200003, [int]$bcdObjectType = 0x12000004 ) # Provided by base script, appears to request elevated privilege when not run as administrator. $cxOptions= new-object System.Management.ConnectionOptions $cxOptions.Impersonation=[System.Management.ImpersonationLevel]::Impersonate $cxOptions.EnablePrivileges=$true # System Management objects: # Use ManagementScope to define base path, including Hostname # Use ManagementPath to describe to WMI object type and arguments for object. # Use ManagementObject to bind the object. $mgmtScope=new-object System.Management.ManagementScope -ArgumentList "\\$Hostname\root\WMI",$cxOptions $mgmtPath=new-object System.Management.ManagementPath -ArgumentList "root\WMI:BcdStore.FilePath=`"`"" $mgmtObject=new-object System.Management.ManagementObject -ArgumentList $mgmtScope,$mgmtPath,$null # Iterates through the objects found in the BcdStore, binds to a BcdObject $mgmtObject.EnumerateObjects($bcdStoreType).Objects | ForEach-Object{ $objPath=new-object System.Management.ManagementPath -ArgumentList "root\WMI:BcdObject.Id=`"$($_.Id)`",StoreFilePath=`"$($_.StoreFilePath)`"" $bcdObject=new-object System.Management.ManagementObject -ArgumentList $mgmtScope,$objPath,$null $bcdElement=$bcdObject.GetElement($bcdObjectType).Element Write-Host $bcdElement.String }