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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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.
ASKER
verynice! Thank you
Glad I could help - thanks for the grade :^)
ASKER
thats nice so far. How should i create the input.csv? Just Header "User"