Script to provide details on Exchange mailboxes
Running Exchange 2007 Server.
I have been given a list of approx 10,000 usernames on an Excel sheet. Management would like me to provide their Exchange mail server, their database, their mailbox size.
The names are located on C:\USERS.xls
I need to amend this file so that the relevant info is next to it.
I was thinking of doing something like get-content C:\Users.txt | foreach-object get XXXXX
Then with the output of the above, copy and paste it into the original XLS file
But does anyone know how I can do this? What script do I need to write?
December 7th, 2011 3:18pm
Try this:
"Get-MailboxStatistics | fl | Export-CSV C:\Users.csv"
Free Windows Admin Tool Kit Click here and download it now
December 7th, 2011 4:13pm
Do you know the full script I would use (get-content etc)?
December 7th, 2011 4:23pm
That should give you users with Exchange mail server, database, and mailbox size information. If C:\Users.txt contains users only, why not copy and paste onto the .csv file?
Free Windows Admin Tool Kit Click here and download it now
December 7th, 2011 4:31pm
Sure but I need this info only for the user listed in C:\Users.xls
If I ran it for everyone I would be returned tens of thousands of results which I don't need
December 7th, 2011 4:37pm
Get-Content Users.xls | Get-mailboxStatistics | fl
Free Windows Admin Tool Kit Click here and download it now
December 7th, 2011 4:45pm
Hi
I wrote a script that might be helpful, be careful that the name start from A1 in excel, If it Start from A2, please change the $row = 1 to $row = 2
-----------------------------------------------------------------------------------------------------------
$excelaccess = New-Object -ComObject Excel.Appllication
$file = (dir C:\USERS.xls).Fullname
$book = $excelaccess.Workbooks.open($file)
$sheet = $book.Worksheets.item(1)
$row = 1
while($true)
{
$name = $sheet.Cells.item($row,1).text
if(!$name)
{
break;
}
else
{
$mb = Get-MailboxStatistics -Identity $name
$sheet.Cells.item($row,2) = $mb.ServerName
$sheet.Cells.item($row,3) = $mb.DatabaseName
$sheet.Cells.item($row,4) = $mb.TotalItemSize.value
}
row++
}
$excelaccess.Quit()
$book = $null
$sheet = $null
$excelaccess = $null
[GC]::Collect()
-------------------------------------------------------------------------------
Cheers
Zi Feng
December 12th, 2011 3:23am
Hi
I wrote a script that might be helpful, be careful that the name start from A1 in excel, If it Start from A2, please change the $row = 1 to $row = 2
-----------------------------------------------------------------------------------------------------------
$excelaccess = New-Object -ComObject Excel.Appllication
$file = (dir C:\USERS.xls).Fullname
$book = $excelaccess.Workbooks.open($file)
$sheet = $book.Worksheets.item(1)
$row = 1
while($true)
{
$name = $sheet.Cells.item($row,1).text
if(!$name)
{
break;
}
else
{
$mb = Get-MailboxStatistics -Identity $name
$sheet.Cells.item($row,2) = $mb.ServerName
$sheet.Cells.item($row,3) = $mb.DatabaseName
$sheet.Cells.item($row,4) = $mb.TotalItemSize.value
}
row++
}
$excelaccess.Quit()
$book = $null
$sheet = $null
$excelaccess = $null
[GC]::Collect()
-------------------------------------------------------------------------------
Cheers
Zi Feng
Free Windows Admin Tool Kit Click here and download it now
December 12th, 2011 11:21am
Hi,
Any update?
How about trying the script from Zi Feng?Rowen
TechNet Community Support
December 13th, 2011 2:16am