OK, truth be told I already know the answer to the question. But, I scoured the net for quite some time on how to do this only to come up short. After piecing together several hints of semi-usable answers I found a couple of solutions that I would like to share for others who may have this same inquiry.
How do you mount a VHDX file to a folder path rather than drive letter using PowerShell?
3.6k Views Asked by Craig At
1
There are 1 best solutions below
Related Questions in POWERSHELL
- PowerShell Linphone Configuration
- How avoid \t being converted to Tab in Powershell
- How do I get my terminal to work in VS Code? Exit Code:2, doesn't allow me to type anything
- Npm command not working in powershell but works in cmd
- Issue with path not being treated as encapsulated when calling cmd /C
- Native command throws error only when I redirect to a variable
- Logic Apps and long running Azure Function (Powershell)
- April fools - PsExec (PsTools)
- How to use nested ForEach-Object
- Batch Script-Powershell MessageBox | How do I set TopMost within PS command line of Batch?
- Execution Stuck at Get-PnPPage if function executed on Button Click
- How can I expand a column from group output?
- How to use expression in regex -replace with capturing group in powershell
- powershell where-object -cnotmatch filter unwanted lines
- How to make Visual Studio 2022 project launch Windows Terminal instead of PowerShell?
Related Questions in MOUNT
- How do I access data from an lvm volume on a drive?
- editing pass option in /etc/fstab with ansible
- Is it possible to mount a logical volume without wiping the data?
- Goofys mount AWS S3 bucket inside container not reloading
- How can we close websockets connection when component unmount?
- rouble with mounting Python code to FUSE: No response and prolonged processing ---
- Unable To Mount Folder In DataBrick
- dislocker: fuse: mountpoint is not empty
- How to mount /home/<my_user>/.ssh folder in devcontainer
- Disconnected Network Drive while connecting to windows using samba
- To do I call Vue app.mount('#myAppID') a second time if the div with that ID is removed from the DOM and added back later?
- How to access files in a mounted persistent disk through a new VM on GCP?
- Podman rootless cannot mount NFS inside container
- docker '--mount' flag not identified while running from a child process
- git commands hanging forever in mounted repositories
Related Questions in VHD
- Rackspace - How to export a Block Storage Volume?
- How to archive big Azure managed disk to storage account as VHD file
- Add-AzureRmVhd : Resource group 'ResourceGroupName' could not be found
- Redirecting file and disk IO calls to VHD
- ERROR: Invalid page blob size: 167816. The size must be aligned to a 512-byte boundary
- Create Azure ARM64 image from VHD
- Convert-vhd or get-vhd throws WMI error - The Hyper-V Management Tools could not access an expected WMI class on computer
- Unable to Deploy Flatcar OS on Azure
- How to remove partition access path without knowing the path of VHD
- SAS URI gets broken when trying to upload the vhd to blob container in a storage account
- Does windows container support to open/attach vhd file at runtime?
- Create Azure linux VHD to use in Pipeline
- download one file from VHD link
- Docker taking up too much space
- Is there a way to dynamically determine the vhdSize flag?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Solution #1 - PowerShell One-Liner... assumes the VHDX has but one volume and the desired mount location already exists in advance.
The reason for the filter after Get-Partition is that I discovered that even though I only saw a single partition in disk manager when I created a VHDX file, there was actually a reserved partition that's not shown in disk manager. The filter removes the attempt to mount that partition.
Solution #2 - Assumes that your VHDX may (or may not) have multiple partitions and that you just want to easily identify each volume by drive number and partition number.
Alternatively, if you want to use the volume label for the partition as is shown in Disk Manager or File Explorer, you can substitute the $PartitionMountPath variable code as follows. Just be sure in advance that the volumes in fact have a name and that they are unique to the drive.
You could also wrap a portion of the Solution #2 code with a foreach loop and use a Get-ChildItem command to pull in multiple VHDX files from a folder location. It seemed a bit over the top to present that as a 3rd solution though.
Anyway... that's what I found for solutions. If you have a better/cleaner way... PLEASE let me know!
As to anyone wondering why I even wanted this in the first place... it was so I could throw this into a Task Scheduler job to auto-mount a VHDX file on boot. Solution #1 was all I really needed, #2 was just a bonus. ;)