Attempted to divide by zero message

Hi

I’m trying to run :

$servers = get-content “C:\Computers.txt”
gwmi Win32_LogicalDisk -ComputerName $servers | where {$.freespace/$.size * 100 -lt 15} |FT PSComputerName,DeviceID, @{n=‘Size(GB)’;e={$.size / 1gb -as [int]}},@{n=‘Free(GB)’;e={$.Freespace / 1gb -as [int]}} ,@{l=‘%FreeDiskSpace’;e={($.FreeSpace / $.Size)*100 -as [int]}}

and I get “Attempted to divide by zero message” message on the spot before the first “$_.freespace”.

Freespace is zero on many kinds of drives, like a DVD. Size can also be zero on some drives.

use

Get-WmiObject -Class Win32_LogicalDisk -Filter “DriveType=3”

if you just want the hard drives

Thanks . Its ok now