Link to home
Start Free TrialLog in
Avatar of timgreen7077
timgreen7077

asked on

Import to CSV from Exchange 2010

I imported a list of users from a CSV file into a variable in EMS so that I can adjust mailbox quota warnings prohitsend and prohibitsendreceive. This worked fine, but I can't see to export the results of these changes to another csv file. Can anyone point me in the right direction.
Avatar of Amit Kumar
Amit Kumar
Flag of India image

use below one:

Get-mailbox -ResultSize unlimited | select Name,PrimarySMTPAddress,issuewarningquota,ProhibitSendquota,ProhibitSendReceiveQuota | Export-csv c:\data.csv

Open in new window

Avatar of timgreen7077
timgreen7077

ASKER

How can I do this just for users in a csv file. When I try the below only 1 user is outputted:

$userlist = import-csv .\limit.csv
foreach ($user in $userlist){
get-mailbox -Identity $user.email | select name,issuewarningquota,prohibitsendquota,prohibitsendreceivequota | Export-Csv .\viewer.csv
}

and the example you gave will search all mailboxes when I only need to get the info for users in the limit csv and then output to new csv named what ever.
Add -append to your Export-CSV cmdlet.

$userlist = import-csv .\limit.csv
foreach ($user in $userlist){
get-mailbox -Identity $user.email | select name,issuewarningquota,prohibitsendquota,prohibitsendreceivequota | Export-Csv .\viewer.csv -append
}

Open in new window

This is the error i got when -append was added:
Export-Csv : A parameter cannot be found that matches parameter name 'append'.

I'm using exchange management shell but powershell 2.0

any other suggestions by chance.
Ohhhhhhh. Powershell 2.0, eh?

Try this:
$userlist = import-csv .\limit.csv
foreach ($user in $userlist){
$results += get-mailbox -Identity $user.email | select name,issuewarningquota,prohibitsendquota,prohibitsendreceivequota
}
$results | Export-Csv .\viewer.csv

Open in new window

This is the error I now get:

+= : Method invocation failed because [System.Management.Automation.PSObject] doesn't contain a method named 'op_Addition'.
At line:2 char:12
+ $results += <<<<  get-mailbox -Identity $user.email | select name,issuewarningquota,prohibitsendquota,prohibitsendreceivequota
    + CategoryInfo          : InvalidOperation: (op_Addition:String) [], RuntimeException
    + FullyQualifiedErrorId : MethodNotFound
Powershell 2.0 (!@$#%!@#@#$)

I have nothing to test with but I think this should work:

$userlist = import-csv .\limit.csv
foreach ($user in $userlist){
    $lo = get-mailbox -Identity $user.email | select name,issuewarningquota,prohibitsendquota,prohibitsendreceivequota
    $results = $results + $lo
 }
$results | Export-Csv .\viewer.csv

Open in new window

Nope same error. I will update WMF and get a more current verison of PS and give it a try.
ASKER CERTIFIED SOLUTION
Avatar of Amit Kumar
Amit Kumar
Flag of India 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
Perfect and thanks.