Link to home
Start Free TrialLog in
Avatar of KAKA JI
KAKA JI

asked on

Exchange

Powershell Script to get mailbox size in MB for list of users in a CSV file with only Samaccountname
Avatar of timgreen7077
timgreen7077

You can run the following:

$userlist = Import-Csv C:\temp\sizes.csv
foreach ($user in $userlist){
Get-MailboxStatistics -Identity $user.samaccountname | select displayname, totalitemsize | Export-Csv c:\temp\results.csv
}

In your csv file name the column 'samaccountname'
Avatar of KAKA JI

ASKER

Thanks TimGreen7077

I need further help

I am getting this error

in : Unexpected token 'in' in expression or statement.
    + CategoryInfo          : ParserError: (in:String) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnexpectedToken
Avatar of KAKA JI

ASKER

[PS] C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Exchange Server 2010>$userlist = Import-Csv "C:\spam\user.csv" foreach($user in $userlist){ Get-MailboxStatistics -Identity $user.SAMAccountName | select displayname, totalitemsize | Export-Csv "c:\spam\results.csv" }
in : Unexpected token 'in' in expression or statement.
    + CategoryInfo          : ParserError: (in:String) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnexpectedToken
Did you copy the last sentence of Tim's script also?  That was instructional in nature and should not be run from the command line.  Here it is separated:

You can run the following:

$userlist = Import-Csv C:\temp\sizes.csv
foreach ($user in $userlist){
Get-MailboxStatistics -Identity $user.samaccountname | select displayname, totalitemsize | Export-Csv c:\temp\results.csv
}

Open in new window

In your csv file name the column 'samaccountname'
ASKER CERTIFIED SOLUTION
Avatar of Todd Nelson
Todd Nelson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks @Jason for clarifying that for the user.

@Kaka tell me the name of your csv file and the version of exchange your are using and I will add it to the script for you.
Avatar of KAKA JI

ASKER

Thanks Todd that worked just fine