PowerCLI – Get all disks with less then 10% free space

Get all disks with less then 10% free space

Get-VM | Get-VMGuest | %{
	$vm = $_
	if($_.Disks){
		$_.Disks | where {($_.FreeSpace/$_.Capacity) -le 0.1 } | %{
			$_ | Select @{N="VMname";E={$vm.VmName}},
				@{N="Path";E={$_.Path}},
				@{N="Free";E={"{0:P}" -f ($_.FreeSpace/$_.Capacity)}}
		}
	}
}

Leave a Reply

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