Scenario: You have a list of mailboxes in a csv file that you need to check the lastlogontime property for each mailbox.
Solution:
#Import CSV $1 = Import-csv C:tempusers.csv #Create the Variable $final = @() #Loop through your users. $1 | %{ $alias = $_.name $2 = Get-mailboxStatistics $_.name | Select DisplayName, LastLogonTime $disp = $2.DisplayName $LastLogon = $2.LastLogonTime #Build the Array $ServerObj = New-Object PSObject $ServerObj | Add-Member NoteProperty -Name "Alias" -Value $alias $ServerObj | Add-Member NoteProperty -Name "DisplayName" -Value $disp $ServerObj | Add-Member NoteProperty -Name "LastLogonTime" -Value $lastlogon $Final += $ServerObj } $final | Export-csv C:tempresults.csv