Link to home
Start Free TrialLog in
Avatar of Mandy_
Mandy_

asked on

Change Powershell script get stats to get user from csv

Dear experts

who can help me with this one below? The input also should come from a csv with 1 column called "user"
with alias or samAccountNamenot no for user at all

Thanks
Mandy

#############################################################################
 # PS-Merge.ps1
 # Description:
 # This script combines three commands and sends the output into a CSV file
 #
 # Jonas Andersson, MCC 2011
 # http://www.testlabs.se/blog
 # Twitter @jonand82
 #############################################################################
 
$Database = @{Name="Database";Expression={ $stats.database }}
 $DisplayName = @{Name="DisplayName";Expression={ $stats.DisplayName }}
 $StorageLimitStatus = @{Name="StorageLimitStatus";Expression={ $stats.StorageLimitStatus }}
 $TotalItemSize = @{Name="MailboxSize";Expression={ $stats.TotalItemSize }}
 $itemcount = @{Name="MailboxSize";Expression={ $stats.itemcount }}
 $Company = @{Name="Company";Expression={ $user.Company}}
 $FirstName = @{Name="FirstName";Expression={ $user.FirstName}}
 $LastName = @{Name="LastName";Expression={ $user.LastName}}
 $LastLogon = @{Name="LastLogon";Expression={ $stats.LastLoggedOnUserAccount}}
 $LastLogonTime = @{Name="LastLogonTime";Expression={ $stats.LastLogonTime}}
 $UserUPN  = @{Name="UPN";Expression={$user.UserPrincipalName}}
 $Primary = @{Name="PrimarySMTP";Expression={$EmailAddress.PrimarySMTPAddress}}
 $Emails   = @{Name="Emails";Expression = { $EmailAddress.EmailAddresses | where { $_.prefixstring -ceq "smtp"}}}
 
 
$Mailboxes = Get-Mailbox -ResultSize Unlimited
 $Mailboxes | foreach {
 $user = Get-User $_
 $stats = Get-MailboxStatistics $_
 $EmailAddress = Get-Mailbox $_
 $_ | select Alias,$DisplayName,$itemcount,$TotalItemSize,$Database,$UserUPN,$Primary,$Emails
 } | Export-CSV -NoTypeInformation C:\AllMailboxesStats.csv

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of sirbounty
sirbounty
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
Avatar of Mandy_
Mandy_

ASKER

hi,

thats nice so far.  How should i create the input.csv?  Just Header "User"
How should i create the input.csv?  Just Header "User"
From your requirements:
The input also should come from a csv with 1 column called "user"
I assumed you already had such a file?  I don't believe you need a header line though.
Avatar of Mandy_

ASKER

verynice! Thank you
Glad I could help - thanks for the grade :^)