How can I create and mount a new VHDX volume without a drive letter assigned? On some servers I get the behaviour described below, on others it works like it should. So there must be a system setting which affect this behaviour besides AutoMount.

I use the following code to create and mount a VHDX volume with Powershell

New-VHD -path $vhdpath -SizeBytes $vhdSize -Dynamic | `
Mount-VHD -NoDriveLetter -Passthru

This creates the VHDX file and mounts ist into the system. Then the DiskManagement window popus up instantly, asking me to initialize the new volume. But I want to initialize, partition and format the volume using scripting.

I found hints to disable the windows AutoMount feature, but this did not help.

Also the system assigns a random drive letter to the volume when I manuall abort the initializing dialog and proceed with the following commands:

$d = InitializeDisk -Number 4 -PartitionStyle GPT
$p = New-Partition -DiskNumber $d.Number -UseMaximumSize -AssignDriveLetter:$False
$v = Format-Volume -Partition $p -FileSystem NTFS -Confirm:$false
Add-PartitionAccessPath -DiskNumber $d.Number -PartitionNumber $p.PartitionNumber -AccessPath "C:\mount"

Then the partition is created and mounted into C:\mount. But the system also assigns a drive letter. I do not want this.

System: Windows Server 2012 R2 Standard Shell: Powershell 4.0


I found the cause of the problem for myself now. There was the USB Drive Letter Manager Service running on the server which showed the suspect behaviour.

Now I stop this service before I create and mount the VHD and start it afterwards again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.