Create an MSR (Microsoft ReseRved) partition in PowerShell

I found an interesting challenge today that I thought I’d share the answer to.  It’s creating an MSR partition in PowerShell WITHOUT using DiskPart.

I can hear people saying, “No that should be easy.”

I thought so too until I tried.

Your first task is actually in knowing HOW to create these custom partition types.   They are part of a GPT partition structure (vs MBR) and are needed in a proper UEFI boot in Windows.

So you can “Cheat” if you like.  You can put together something in Diskpart and it will work nicely.   But I like to figure out how in Windows PowerShell since I can easily target disks and Partitions with it by the object.

First you’ll need to know the different Guid’s for the GPT partition types.   You can get these by doing the following Cmdlet

Get-Help Get-Partition –online

This will bring you directly to very up to date online version of PowerShell H elp for the Get-Partition Cmdlet.

Drilling down the screen you’ll note reference to the four GPT partition types which are identified by numbers.


Specifies the type of GPT partition to create (by GUID). By default, the New-Partition cmdlet creates a basic GPT data partition.

The GUIDs of valid types are:
— System Partition (c12a7328-f81f-11d2-ba4b-00a0c93ec93b)
— Microsoft Reserved (e3c9e316-0b5c-4db8-817d-f92df00215ae)
— Basic data (ebd0a0a2-b9e5-4433-87c0-68b6b72699c7)
— Microsoft Recovery (de94bba4-06d1-4d40-a16a-bfd50179d6ac)

So to create a partition we might do something like this which follows a process of

Get a Disk you’re interested in and store that object away

Create a partition targeting the Disk object providing the Size, partition Type and the flavour of Banana Ice cream you’d like on it.

I threw that last bit in just to see if you were reading Winking smile

So presuming I’m working with a VHD file called SAMPLE.VHD it might look something like this

$Disk=Get-VHD .\Sample.vhd | Get-Disk

$Partition=New-Partition –DiskNumber $Disk.Number –Size 300MB –GptType ‘{e3c9e316-0b5c-4db8-817d-f92df00215ae}’

We would next normally Format it like so

Format-Volume –FilesystemLabel ‘Reserved’ –FileSystem Fat32 –Partition $Partition.PartitionNumber

…or something like that.  If you TRIED that you’d get a nasty vile message indicating it can’t enumerate CIM or something scary.

The REAL answer is an MSR partition is like a locked door when you make it.    So you have to “Trick” Windows into letting you make AND format one.

So the answer is pretty easy.   Create a Basic partition, format it and then CONVERT it to an MSR.  The File system is the same but it’s only a matter of flipping the bits on the partition.

To make this a Reserved Partition (MSR) we simply do THIS.

$Disk=Get-VHD .\Sample.vhd | Get-Disk

$Partition=New-Partition –DiskNumber $Disk.Number –Size 300MB

$Partition | Format-Volume –Filesystem Fat32 –NewFileSystemLabel ‘Reserved’

$Partition | Set-Partition –DiskNumber $Disk.Number –PartitionNumber $Partition.PartitionNumber –GptType ‘{e3c9e316-0b5c-4db8-817d-f92df00215ae}’

Tada!   The same process also works for creating a Reserved partition (other than the other Guid)


There you go! It’s all just a Cmdlet away!

The Energized Tech


Get every new post delivered to your Inbox.

Join 3,611 other followers