$strPath="C:\powershell\test.xls"shell
$objexcel=New-Object -ComObject excel.applicationapp
$objexcel.Visible=$falseide
$workbook=$objexcel.Workbooks.add()ui
$sheet=$workbook.worksheets.item(1)excel
$x=2ip
$strComputer="."it
$objwmi=Get-WmiObject -Class win32_shareio
$sheet.cells.item(1,1)=("Name of Share")class
$sheet.cells.item(1,2)=("Description of share")test
$sheet.cells.item(1,3)=("Type of share")
foreach($objshare in $objwmi)
{
$sheet.cells.item($x,1)=$objshare.Name
$sheet.cells.item($x,2)=$objshare.Description
$sheet.cells.item($x,3)=$objshare.type
$x++
}
$range=$sheet.usedrange
$range.Entirecolumn.autofit()
$objexcel.ActiveWorkbook.SaveAs($strPath)
$objexcel.quit()
$range=$null
$sheet=$null
$workbook=$null
$objexcel=$null
[gc]::collect()