Search code examples
powershellwinpe

Get drive letters from physical disk number under WinPE


I have a WinPE iso copied to an USB stick. In the WinPE environment the user enters a physical disk number. I want to create a warning if this physical disk looks like the WinPE disk.

My solution is to check whether the folders on it corresponds to the WinPE disk content. To do this I need the drive letter in order to Test-Path.

It looks like this solution Combine Get-Disk info and LogicalDisk info in PowerShell?.

But it does not work in WinPE environment: Some WMI doesn't work in Windows PE.

How can I check the content of the selected physical disk?


Solution

  • I've got something better for you, in the registry it stores what drive letter it booted from. HKLM\SYSTEM\CurrentControlSet\Control\PEBootRamdiskSourceDrive

    Edit To clarify if the you booted WinPE from a flash drive and it got assigned D:, then the value of that entry would be D: