Skip to main content

Measure-VolumeSpace

Description

This document provides a guide to measuring volume space and determining if volumes are low on space based on specified parameters.

Requirements

  • PowerShell v5
  • Must be run as an Administrator

Usage

  1. All parameters are validated before processing.
  2. Volumes to process are gathered based on the passed parameters.
  3. Each gathered volume is then looped through:
    • Determine the size type (Small, Medium, Large, X-Large) of the volume.
    • Apply the threshold rule set based on the size type.
    • Add the volume to the list of low space volumes if it is found to be low.
  4. Return the list of low space volumes.

Searches for all fixed volumes with drive letters and returns those that are low on space based on the default parameters.

.\Measure-VolumeSpace.ps1

Searches for all fixed volumes with drive letters and a size greater than or equal to 100MB, returning volumes that are low on space. The maximum size for a 'small' drive is 20GB, meaning that medium drives will be between 20GB and the default 1024GB. The medium drive type uses a percentage-based threshold of 20%.

.\Measure-VolumeSpace.ps1 -MinimumSize 100MB -SmallVolumeMaxSize 20GB -MediumVolumeThresholdType 'Percent' -MediumVolumeThreshold 20

Searches for all fixed and removable volumes, with or without drive letters, returning those that are low on space based on the default parameters.

.\Measure-VolumeSpace.ps1 -d 'Fixed', 'Removable' -u

Searches for all fixed volumes with drive letters except 'C', returning those that are low on space based on the default parameters.

.\Measure-VolumeSpace.ps1 -e 'C'

Searches for all fixed volumes with drive letters, suppressing all console output except for the return object, and returning volumes that are low on space based on the default parameters.

.\Measure-VolumeSpace.ps1 -Quiet

Parameters

ParameterAliasRequiredDefaultTypeDescription
MinimumSizesmFalse1MBInt64The minimum size of the volume to search for. Any volume under this limit will be excluded.
SmallVolumeMaxSizessFalse256GBInt64The maximum size of what should be considered a 'small' drive.
SmallVolumeThresholdstFalse11Int64The threshold to consider a 'small' volume low on space. If $SmallVolumeThresholdType is set to 'Percent', this should be less than or equal to 100.
SmallVolumeThresholdTypesttFalse'Percent'StringThe type of threshold calculation to perform for 'small' drives. Valid options are 'Percent' and 'Number'.
MediumVolumeMaxSizemsFalse1024GBInt64The maximum size of what should be considered a 'medium' drive.
MediumVolumeThresholdmtFalse11Int64The threshold to consider a 'medium' volume low on space. If $MediumVolumeThresholdType is set to 'Percent', this should be less than or equal to 100.
MediumVolumeThresholdTypemttFalse'Percent'StringThe type of threshold calculation to perform for 'medium' drives. Valid options are 'Percent' and 'Number'.
LargeVolumeMaxSizelsFalse2048GBInt64The maximum size of what should be considered a 'large' drive.
LargeVolumeThresholdltFalse5Int64The threshold to consider a 'large' volume low on space. If $LargeVolumeThresholdType is set to 'Percent', this should be less than or equal to 100.
LargeVolumeThresholdTypelttFalse'Percent'Int64The type of threshold calculation to perform for 'large' drives. Valid options are 'Percent' and 'Number'.
XLargeVolumeThresholdxtFalse5Int64The threshold to consider an 'x-large' volume low on space. If $XLargeVolumeThresholdType is set to 'Percent', this should be less than or equal to 100.
XLargeVolumeThresholdTypexttFalse'Percent'Int64The type of threshold calculation to perform for 'x-large' drives. Valid options are 'Percent' and 'Number'.
DriveTypesdFalse'Fixed'String[]A list of the types of drives to review space for. Valid options are:
- 'Unknown'
- 'Invalid Root Path'
- 'Removable'
- 'Fixed'
- 'Remote'
- 'CD-ROM'
- 'RAM Disk'
IncludeUnassignedVolumesuFalseFalseSwitchUse this switch to include volumes that have not been assigned a drive letter.
ExcludeDriveLetterseFalseString[]A list of drive letters to exclude from the review.
QuietqFalseFalseSwitchSuppresses all console output other than the return object by overwriting the Write-Host function.

Output

Microsoft.Management.Infrastructure.CimInstance#ROOT/Microsoft/Windows/Storage/MSFT_Volume

  • .\Measure-VolumeSpace-log.txt
  • .\Measure-VolumeSpace-error.txt