How To Display Mount Points and Drives Using PowerShell


To continue on with more useful PowerShell we cover getting details on drives including drives that are using mount points.

The Code

For the most part we will be making a call to WMI using win32_volumes class and using auto format to output to a table. In the output we want to display Disk free space, total space, disk percentage as well as name and  drive letter. The name output includes the full path to the mount point.


# Name getmntptdtls.ps1
# This will output specific details for mountpoints

$TotalGB = @{Name="Capacity(GB)";expression={[math]::round(($_.Capacity/ 1073741824),2)}}
$FreeGB = @{Name="FreeSpace(GB)";expression={[math]::round(($_.FreeSpace / 1073741824),2)}}
$FreePerc = @{Name="Free(%)";expression={[math]::round(((($_.FreeSpace / 1073741824)/($_.Capacity / 1073741824)) * 100),0)}}

function get-mountpoints {
$volumes = Get-WmiObject win32_volume -Filter "DriveType='3'"
$volumes | Select Name, Label, DriveLetter, FileSystem, $TotalGB, $FreeGB, $FreePerc | Format-Table -AutoSize



So what does it look like?



Another task handled by PowerShell, happy coding.

3 Responses to “How To Display Mount Points and Drives Using PowerShell”

  1. Chuck King says:

    I am new to PowerShell and like your code. How would you output the results to a csv file?

    • newlife007 says:

      I appreciate the comments, I try to keep the scripts easy to read and use. PowerShell makes it easy with cmdlet Export-CSV, just replace the Format-table with Export-CSV -path c:\Support\myfile.csv -append

  2. Dale says:

    I have enjoyed reading your PSH posts on storage related topics. Do you have any code that will tie Cluster Disks back to the Array Device Names? Specifically EMC or Hitachi? If I can tie the cluster disk back to the local disk I can decipher the DEV through the Get-Disk cmdlet.

    If you ever need it for Hitachi Arrays here is that method:

    Get-Disk | Sort-Object -Property Number | ForEach-Object {
    Write-Host(“Found DEV: “+$currentSelectedDisk.UniqueId.SubString(28)+” Disk Number: “+$currentSelectedDisk.Number)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.