?
Solved

Combining Get-Mail & Get-Mailboxstatistics To Pull UsageLocation & LastLogonTime

Posted on 2014-03-27
2
Medium Priority
?
2,686 Views
Last Modified: 2014-03-28
I'm trying to use Get-Mailbox & Get-Mailboxstatistics to pull all user's names, UsageLocation, CustomAttribute1 and LastLogonTimes, into a CSV file. If I use the below PowerShell scripts for a single user, it pulls all the information, including LastLogonTime.

"Name","UsageLocation","CustomAttribute1","LastLogonTime"
"Bloggs, Joe","United States","New York","27/03/2014 15:15:01"

However as soon as I replace the username with '-ResultSize 10' or '-ResultSize Unlimited', it only seems to pull LastLogonTime for the last 1 or 2 records, all the rest are just blank.

"Name","UsageLocation","CustomAttribute1","LastLogonTime"
"Johnson, Joe","Canada","Burlington",
"Bloggs, Joe","United States","New York",
"Smith, John","Canada","Whitby","27/03/2014 17:12:39"

How can I get the LastLogonTimes, along with all the other information using these PS commands?

Get-Mailbox "Bloggs, Joe" | Select Name, UsageLocation, CustomAttribute1, @{n='LastLogonTime';e={ ($_ | Get-Mailboxstatistics).LastLogonTime }} | Export-Csv c:\LastLogonTime.csv -encoding UTF8

Open in new window

0
Comment
Question by:bjblackmore
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 19

Accepted Solution

by:
Raheman M. Abdul earned 2000 total points
ID: 39960937
Pipe the "get-mailbox ... -resultsize 10" to sort-object then use select will give the proper results

check this article:http://social.technet.microsoft.com/Forums/exchange/en-US/82d5d38a-0c13-4c16-b1b0-9999c00d354d/mailbox-size-reports-and-other-stuff-exchange-powershell-2010?forum=exchange2010
0
 

Author Comment

by:bjblackmore
ID: 39961515
Thanks for the reply. I managed to use that article to produce the below code. Takes about 75minutes to run for all 5,000 users, but manages to pull the information requied. Thanks!

Get-Mailbox -ResultSize Unlimited | sort-object | Select-Object Name, UsageLocation, CustomAttribute1,@{n="LastLogonTime";e = {$MBXstat = Get-MailboxStatistics $_.name; $MBXstat.LastLogonTime}} | Export-Csv C:\temp\LastLogonTime.csv -encoding UTF8

Open in new window

0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
This article will help to fix the below errors for MS Exchange Server 2013 I. Certificate error "name on the security certificate is invalid or does not match the name of the site" II. Out of Office not working III. Make Internal URLs and Externa…
In this video we show how to create an Address List in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Organization >> Ad…
In this video we show how to create an Accepted Domain in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Mail Flow >> Ac…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question