$excel = new-object -comobject Excel.Application
$workbooks = $excel.Workbooks.Add()
$worksheets = $workbooks.worksheets
$worksheet = $worksheets.Item(1)
$worksheet.Name = “drive details”
$worksheet.Cells.Item(1,1) = “Name”
$worksheet.Cells.Item(1,2) = “Used”
$worksheet.Cells.Item(1,3) = “Free”
$worksheet.Cells.Item(1,4) = “Root”
$a=get-psdrive
$x=2
$y=1
$a
foreach($s in $a)
{
if($s.Free -gt 0)
{
$worksheet.Cells.Item($x,$y)=$s.Name
$y++
$worksheet.Cells.Item($x,$y) =$s.Used
$y++
$worksheet.Cells.Item($x,$y) = $s.Free
$y++
$worksheet.Cells.Item($x,$y) =$s.Root
$x++
$y=1
}
}
$excel.Visible=$true