#----------------Function NEWEXCEL------------
Function NewExcel ($users2, $dir2)
{
$Excel = New-Object -Com Excel.Application
#$Excel.visible = $True
$Book = $Excel.Workbooks.Add()
$Sheet = $Book.WorkSheets.Item(1)
$Sheet.Cells.Item(1,1) = "User Name"
$Sheet.Cells.Item(1,2) = "Size (GB)"
$WorkBook = $Sheet.UsedRange
$WorkBook.Font.Bold = $True
$sheet.name = "$dir2"
$intRow = 2
foreach ($user in $users2) {
$sheet.Cells.Item($intRow,1) = $user.MailboxDisplayName
$sheet.Cells.Item($intRow,2) = "{0,7:n2}" -f ($user.Size / 1MB)
$Introw++
}
$WorkBook.EntireColumn.AutoFit()
$sheet.SaveAs("c:\$date\$date-$dir2")
$excel.quit()
}
#-----------------------------------------------
|