Saturday, October 21, 2017

Determining the volume of a specified file in PowerShell

NTFS makes it possible to mount one volume in an empty directory of another. Files on the mounted volume will be accessible through paths that appear to be on the host volume. One might wonder, then, how the true volume can be identified given a full path. I wrote a script in this Super User answer that does exactly that. It works by listing the mount points via WMI and finding the one that accounts for the largest chunk of the file path. Then it just issues a Get-Volume on the determined volume so that a volume object is returned.

No comments:

Post a Comment