Assign a mount point folder path to a drive using PowerShell Assign a mount point folder path to a drive using PowerShell powershell powershell

Assign a mount point folder path to a drive using PowerShell


The Commandlet that I needed was Add-PartitionAccessPath

I set things up the way I wanted through the GUI on disk 2, created a partion on Disk 3 and then carefully compared the properties.The key was here:

(Get-Partition -DiskNumber 2).AccessPaths(Get-Partition -DiskNumber 3).AccessPaths

There was an additional AccessPath for Disk2, which led me across a number of MSDN articles looking for a method, until I finally found that there already is a command for it.

The following command sealed the deal:

$Partition | Add-PartitionAccessPath -AccessPath "G:\Folder01"

For reference, here's the full solution:

$Disk = Get-Disk 3# $Disk | Clear-Disk -RemoveData -Confirm:$false$Disk | Initialize-Disk -PartitionStyle MBR$disk | New-Partition -UseMaximumSize -MbrType IFS$Partition = Get-Partition -DiskNumber $Disk.Number$Partition | Format-Volume -FileSystem NTFS -Confirm:$falseNew-Item -ItemType Directory -Path "G:\Folder01"$Partition | Add-PartitionAccessPath -AccessPath "G:\Folder01"


How to assign a drive to a NTFS Folder in Powershell using Command Line:

cmd /c 'subst G: "C:\Folder1"'

Note: Explorer is showing the same size of the folder as the C:.


If you're looking at putting files into some folder, and expect them to end up being stored on some disk then there's MOUNTVOL.

To find drive/volume name:

MOUNTVOL

TO remove the drive letter & instead mount on an empty NTFS folder:

mountvol e: /dmountvol c:\<path> <volume name> eg. mountvol c:\fakedisk\ \\?\Volume{########-####-####-####-############}\

So in above example, everytime to write to c:\fakedisk\ folder, the data will end up in what used to be e: drive (disk/device). This is opposite to subst, which "Associates a path with a drive letter", so writing data to the drive will get stored in that path/folder.

Tested on Win 10CMD