PowerShell to create a directory within a junction point; or within a volume with no drive letter?

232 Views Asked by At

I'm working with Hyper-V and clustering in a Server 2016 environment. This is something I'm new to, and I'm trying to utilize some of my PowerShell experience to script the creation of a new folder within a shortcut (junction point, specifically), OR within a volume label that does not reflect an associated drive letter.

Under the directory C:\ClusterStorage there are shortcuts/junction points for the following: Volume1, Volume2, Volume3. I want to create a new child directory called "Hyper-V", within the Volume1 junction point. However, when I try to run the below script, even though I'm designating C:\ClusterStorage\Volume1.lnk as the existing directory, and designating \Hyper-V as the new directory that I want to create as the subdirectory, the script tells me the Volume1.lnk already exists, as if it's trying to create the $rootpath anyway:

$rootpath = "C:\ClusterStorage\Volume1.lnk"
$newpath = "\Hyper-V"
New-Item -Path $rootpath -Value $newpath -ItemType Directory | Out-Null

So I'm not sure if there is a better approach to the above method I was trying (I cannot seem to find anything else). My other thought was to go directly to the source, if you will. Once the cluster is created properly, the Volume1 junction point actually points to a volume named Backups. This volume has a drive letter assigned within Disk Management initially, but for whatever technical reason, once the cluster is fully-configured properly the drive letter is no longer associated with the volume.

I do not want to create a new drive letter for the Backups volume, for fear that it will tamper with the cluster configuration, so I was wondering if perhaps there's a means of using PowerShell to create the Hyper-V subdirectory within the volume named Backups. I can only seem to find topics on "Add-PartitionAccessPath" when I search for a means of doing this, and Add-PartitionAccessPath seems to assign a drive letter, which I don't want to do as I mentioned.

Is what I'm trying to accomplish here possible? It seems using md hyper-v within C:\ClusterStorage\Volume1 (using CMD Prompt) works exactly as I want, if that helps. I'm just looking to do the same in PowerShell syntax. Thanks so much!

0

There are 0 best solutions below