PowerShell for Windows Admins

Jan 12 2010   2:41AM GMT

Disks Part 4: Mount points

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

We have seen how to discover our physical and logical disks.  In a quick digression I want to cover Mount Points.  These allow us to mount the volume into an empty folder in the file system rather than having a new drive. They are useful when we have lots of volumes and need to conserve drive letters.

Get-WmiObject -Class Win32_MountPoint | 
where {$_.Directory -like ‘Win32_Directory.Name="C:\\Data*"’} | 
foreach {
    $vol = $_.Volume
    Get-WmiObject -Class Win32_Volume | where {$_.__RELPATH -eq $vol} | 
    Select @{Name="Folder"; Expression={$_.Caption}}, 
    @{Name="Size (GB)"; Expression={"{0:F3}" -f $($_.Capacity / 1GB)}},
    @{Name="Free (GB)"; Expression={"{0:F3}" -f $($_.FreeSpace / 1GB)}},
    @{Name="%Free"; Expression={"{0:F2}" -f $(($_.FreeSpace/$_.Capacity)*100)}}

Our win32_MountPoint class only gives us directory and volume ID information.  if we want more we have to link to the Win32_Volume class.

As we know where we have mounted our volumes we can filter on that folder – note the use of c:\\data  – the \\ is a WMI syntax to escape the \.

For each mount point we find a volume with the correct ID.  I’ve use __RELPATH in the filter as it takes the same syntax as the ID in win32_mountpoint so we don’t need to do any processing.  Once we have our volume we can format the data in the way we have seen previously.

Technorati Tags: ,,

 Comment on this Post

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: