Exchange Powershell help for a noob

Associate
Joined
26 Nov 2004
Posts
980
Location
Carshalton, Surrey
OK so basically what i want to do is create a csv file with the diplayname, server, Alias and size of a set of users from a csv file

$ukstats = Import-Csv "D:\PS_scripts\data_files\Alpha\teststats-uk.csv"
$ukstats | foreach {
Get-MailboxStatistics -identity $_.name | select displayname, servername, Alias, totalitemsize | Export-Csv D:\PS_scripts\data_files\Alpha\mailboxresultsuk.csv
}

This is what I have above, the problem I have is that it creates the export but only has the last user from the import file. Why is it not doing it for each user in turn? I don't really do the powershell side of things that's my colleague but he's on holiday for two weeks and as is always the case management want this info asap.
 
Associate
OP
Joined
26 Nov 2004
Posts
980
Location
Carshalton, Surrey
Thanks for that i will give it a try, as to the csv import that's probably just me not knowing a better way of doing it. I tried the get-content command with it pointing to a txt file but could not get it to work.

Essentially the reason behind it is that i only need to get the information for a subset of our users and the csv well its actually just a txt file, is just populated with the usernames of those users in a single column.
 
Associate
OP
Joined
26 Nov 2004
Posts
980
Location
Carshalton, Surrey
The users are stored in various different OU's and no possibility of moving them, my company has sold part of the business and the list i have is those employee's that will be tuped over to the new company, the list is based on their employee number which is also the username so I have the export from the HR DB of those that will be going, hence the reason for the imported csv.

Your first one has worked perfectly thank you, one more question if I may if I need to get results from both get-mailbox and mailboxstatistics how would that work with your first suggestion.

For example if i needed alias and distinguished name which are not available with mailboxstatistics.
 
Associate
OP
Joined
26 Nov 2004
Posts
980
Location
Carshalton, Surrey
Thanks very much for the help that is perfect gives me the ability to add in more info when management inevitably come back asking for more. I only have about 700 users to collect the data from for this round so speed should be pretty quick i think.
 
Back
Top Bottom