How to filter partitions/volumes out from wmi32_volume

Hi

I’m creating a report to report daily on our servers that start running low on disk space.

We have a large number of volumes that are connected to mount points so collecting volumes with drive letter won’t give me the full picture.

I’m using this commend:

$DiskDrives=Get-WmiObject -ComputerName $Server -Class Win32_Volume -Filter “DriveType = 3”

This gives me what I want except that it also includes the 2 small partitions on Disk 0, the recovery and EFI System partitions. Sometimes they have a label that is easy enough to filter out, however that seems to be a rarity.

How can I filter out these two out of $DiskDrives?

Cheers

Matt

You could use

Get-CimInstance -ClassName Win32_LogicalDisk

Hi Matt,

If you are looking for low disk space, PowerShell has a `Get-Volume` Cmdlet to retrieve volume information. You will be able to pipe out to Where-Object to filter your results. Check out all of the other Cmdlets that are available for storage.

Storage Module

pwshliquori