rdefino
asked on
Need script to pull some details on exchange mailboxes
I'm running exchange 2007 and I have a list of about 1000 mailboxes that I need to get the following details on. How can I take acsv or text file with teh mailbxes and pull this data for each?
• Size of mailbox
• Last logged on with own account
• Last time mail received
thanks
• Size of mailbox
• Last logged on with own account
• Last time mail received
thanks
ASKER
thanks. How to use this script to use a list of accounts from a text file or cvs file. I have about 1000 accounts to check.
I would just run it against all mailboxes, then you can edit the CSV output. Running the command like I listed it will give you ALL mailboxes.
If you want a subset based on a CSV/txt file you already have, it can be done. Don't have that off the top of my head though. Let me see what I can put together.
If you want a subset based on a CSV/txt file you already have, it can be done. Don't have that off the top of my head though. Let me see what I can put together.
Try this -
Import-CSV C:\Users.csv | ForEach {Get-Mailbox -Identity "$($_.Name) *"} | get-mailboxstatistics | select-object DisplayName,TotalItemSize, LastLogonT ime,LastLo ggedOnUser Account | export-csv file.txt
The $_.Name corresponds to the users full name. You can substitute any number of variables there, include alias (For their AD account), etc. To see all of these, pick one user and do this format -
get-mailbox useralias | fl *
Substitute useralias above with the users actual alias (smithj, for example). You'll see ALL information, and then you can pick and choose the fields to work with.
Import-CSV C:\Users.csv | ForEach {Get-Mailbox -Identity "$($_.Name) *"} | get-mailboxstatistics | select-object DisplayName,TotalItemSize,
The $_.Name corresponds to the users full name. You can substitute any number of variables there, include alias (For their AD account), etc. To see all of these, pick one user and do this format -
get-mailbox useralias | fl *
Substitute useralias above with the users actual alias (smithj, for example). You'll see ALL information, and then you can pick and choose the fields to work with.
ASKER
the only issue with getting all mailboxes is then I have to sort out the 1000 or so I need. We have upwards of 10000 mailboxes in our environment.
Ahhh, yes, that makes a LOT more sense. If you have a way that you delineate them in AD, we could use that as well. FYI.
ASKER
I get this error when running the script against my csv file. I edited out the name of the dc in the error.
Get-Mailbox : The operation could not be performed because object ' *' could not be found on domain controller
'xxxxxxxxx.com'.
At line:1 char:40
+ Import-CSV e:\mailboxes.csv | ForEach {Get-Mailbox -Identity "$($_.Name) *"} | g ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Get-Mailbox], ManagementObjectNotFoundEx ception
+ FullyQualifiedErrorId : 2329A700,Microsoft.Exchang e.Manageme nt.Recipie ntTasks.Ge tMailbox
Get-Mailbox : The operation could not be performed because object ' *' could not be found on domain controller
'xxxxxxxxx.com'.
At line:1 char:40
+ Import-CSV e:\mailboxes.csv | ForEach {Get-Mailbox -Identity "$($_.Name) *"} | g ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Get-Mailbox], ManagementObjectNotFoundEx
+ FullyQualifiedErrorId : 2329A700,Microsoft.Exchang
Drop the * - so -
Import-CSV C:\Users.csv | ForEach {Get-Mailbox -Identity "$($_.Name)"} | get-mailboxstatistics | select-object DisplayName,TotalItemSize, LastLogonT ime,LastLo ggedOnUser Account | export-csv file.txt
Just to make sure - you're running this under Exchange Powershell, right?
Import-CSV C:\Users.csv | ForEach {Get-Mailbox -Identity "$($_.Name)"} | get-mailboxstatistics | select-object DisplayName,TotalItemSize,
Just to make sure - you're running this under Exchange Powershell, right?
ASKER
yes, exchange shell.
but it still failing:
Get-Mailbox : Cannot bind parameter 'Identity'. Cannot convert value "" to type
"Microsoft.Exchange.Config uration.Ta sks.Mailbo xIdParamet er". Error: "The parameter value of this type
Microsoft.Exchange.Configu ration.Tas ks.Mailbox IdParamete r cannot be empty.
Parameter name: identity"
At line:1 char:62
+ Import-CSV e:\mailboxes.csv | ForEach {Get-Mailbox -Identity "$($_.Name)"} | get ...
+ ~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-Mailbox], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMes sage,Micro soft.Excha nge.Manage ment.Recip ientTasks. GetMailbox
Get-Mailbox : Cannot bind parameter 'Identity'. Cannot convert value "" to type
but it still failing:
Get-Mailbox : Cannot bind parameter 'Identity'. Cannot convert value "" to type
"Microsoft.Exchange.Config
Microsoft.Exchange.Configu
Parameter name: identity"
At line:1 char:62
+ Import-CSV e:\mailboxes.csv | ForEach {Get-Mailbox -Identity "$($_.Name)"} | get ...
+ ~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-Mailbox], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMes
Get-Mailbox : Cannot bind parameter 'Identity'. Cannot convert value "" to type
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Let me give this a try, thanks
ASKER
Was able to pull the info. thanks
get-mailbox | get-mailboxstatistics | select-object DisplayName,TotalItemSize,
Not sure if there's a way to get the last email received, so I included lastlogontime (Figured maybe you're trying to clean up old mailboxes.) Let me keep digging.
Edit - missed that you want last logged on with own account. That's not tracked. You can add LastLoggedOnUserAccount to see who last logged in. So -
get-mailbox | get-mailboxstatistics | select-object DisplayName,TotalItemSize,