Hi,
When you try to combine Get-mailbox with Get-MailboxStatistics and export it to csv-file, You will get nothing from the last command.
So here is a script that will allow You export the following.
From Get-Mailbox = Name
From Get-Mailbox = UserPrincipalName
From Get-Mailbox = Alias
From Get-MailboxStatistics = LastLogonTime
From Get-MailboxStatistics = LastLogofTtime
From Get-MailboxStatistics = Servername
From Get-MailboxStatistics = Databasename
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
$DataPath = "C:\folder\Mailboxes.csv" $Results = @() $MbxUsers = get-mailbox -resultsize unlimited foreach($user in $mbxusers) { $UPN = $user.userprincipalname $Mbx = Get-MailboxStatistics $UPN $Properties = @{ Name = $user.name UPN = $UPN Alias = $user.alias Logon = $Mbx.lastlogontime Logoff = $Mbx.lastlogofftime Server = $Mbx.servername DatabaseInstructions = $Mbx.databasename } $Results += New-Object psobject -Property $properties } $Results | Select-Object Name,UPN,Alias,Logon,Logoff,Server,DatabaseInstructions | Export-Csv -nti -enc utf8 -Path $DataPath |