function Get-LocalHardDrives { <# .SYNOPSIS Get the local hard drive information for this computer .PARAMETER IncludeRemovableDisks Get the information of removable disks as well .OUTPUTS Returns a [object[]] of drive info. See also ConvertTo-DriveInfo #> [CmdletBinding()] [OutputType([string[]])] param ( $IncludeRemovableDisks ) <# Drive types for the CIM Instance response are: 0 = Unknown 1 = No Root directory 2 = Removable Disk 3 = Local Disk 4 = Network Drive 5 = Compact Disc 6 = Ram Disk #> $driveTypeFilter = @(3) $return = @() if ($IncludeRemovableDisks) { $driveTypeFilter += 2 } $drives = (Get-CIMInstance -Class Win32_LogicalDisk) foreach ($drive in $drives) { if ($driveTypeFilter -contains $drive.DriveType) { $return += (ConvertTo-DriveInfo -CimInstance $drive) } } return $return }