Solved

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

Posted on 2014-03-27
2
2,436 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
2 Comments
 
LVL 18

Accepted Solution

by:
Raheman M. Abdul earned 500 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Lotus Notes – formerly IBM Notes – is an email client application, while IBM Domino (earlier Lotus Domino) is an email server. The client possesses a set of features that are even more advanced as compared to that of Outlook. Likewise, IBM Domino is…
Scam emails are a huge burden for many businesses. Spotting one is not always easy. Follow our tips to identify if an email you receive is a scam.
In this video we show how to create a Distribution Group 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 Recipients >>…
In this video we show how to create a Resource Mailbox in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: Navigate to the Recipients >> Resources tab.: "Recipients" is our default selection …

912 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now