我已将VHD附加到diskpart,磁盘编号为2
。 $drive_ltrs = (get-partition -disknumber 2).driveletter
返回D
。如果现在我将W
分配给EFI分区,D
将被删除。为什么会这样?
${vol_letter_efi} = get-partition | where-object {$_.GptType -eq "{C12A7328-F81F-11D2-BA4B-00A0C93EC93B}"} | select-object -first 1 DriveLetter
${vol_letter_efi} = ${vol_letter_efi}.DriveLetter
if([string]${vol_letter_efi} -eq ""){
${vol_letter_efi} = get_efi_partition_letter %just returns W
$part_nr_efi = get-partition | where-object {$_.GptType -eq "{C12A7328-F81F-11D2-BA4B-00A0C93EC93B}"} | select-object -first 1 PartitionNumber
$part_nr_efi = $part_nr_efi.PartitionNumber
Get-Partition -PartitionNumber $part_nr_efi | Set-Partition -NewDriveLetter ${vol_letter_efi}
}