Author Posts

May 27, 2016 at 12:12 pm

Hi All

i have a csv, content like below

mark.prior@contoso.com
James.dean@contoso.com

now when i pipe this to get-mailboxstatistics as below i get the expected result,

{Pre} get-content "c:\temp\email2.csv" | Get-MailboxStatistics | Select DisplayName, database, LastLog* | Out-GridView
{/pre}

DisplayName Database etc...... etc.......
——————– ————- ———- ———

Mark Prior blah
James Dean blaa_1

however i would like the original csv input posted alongside the generated result

DisplayName Database etc...... etc....... Orignal Input
——————– ————- ———- ——— ——————–

Mark Prior blah mark.prior@contoso.com
James Dean blaa_1 James.dean@contoso.com

thanks much guys

p.s like the new forum

May 27, 2016 at 12:21 pm

get-content "c:\temp\email2.csv" | Get-MailboxStatistics | Select DisplayName, database, LastLog* | Out-GridView

dang cant edit original to correct code

May 27, 2016 at 12:29 pm

$csv = import-csv "c:\temp\email2.csv"

foreach($user in $csv){

$mbxstats = Get-MailboxStatistics $user

[pscustomobject]@{

prop1 = $user.column1
prop2 = $user.column1
prop3 = $mbxstats.property1
prop4 = $mbxstats.property2
#etc..
}

}

May 27, 2016 at 1:54 pm

great thanks, ended up using get-content as import-csv was erroring
end script

$csv = get-content "c:\temp\email1.csv"
foreach($user in $csv){

$mbxstats = Get-MailboxStatistics $user

[pscustomobject]@{

'Email Address' = $user
'Database Location' = $mbxstats.DatabaseName
'Last Accessed By' = $mbxstats.LastLoggedOnUserAccount
'Last Logon Time' = $mbxstats.LastLogonTime
} 

}

how would i output this to gridview ?

May 27, 2016 at 2:14 pm

either assign variable before the foreach or pipe after the last bracket


$csv = get-content "c:\temp\email1.csv"
$output = foreach($user in $csv){

$mbxstats = Get-MailboxStatistics $user

[pscustomobject]@{

'Email Address' = $user
'Database Location' = $mbxstats.DatabaseName
'Last Accessed By' = $mbxstats.LastLoggedOnUserAccount
'Last Logon Time' = $mbxstats.LastLogonTime
} 

}

$output | out-gridview

$csv = get-content "c:\temp\email1.csv"
foreach($user in $csv){

$mbxstats = Get-MailboxStatistics $user

[pscustomobject]@{

'Email Address' = $user
'Database Location' = $mbxstats.DatabaseName
'Last Accessed By' = $mbxstats.LastLoggedOnUserAccount
'Last Logon Time' = $mbxstats.LastLogonTime
} 

} | out-gridview

May 27, 2016 at 2:36 pm

thanks dan thats great