Get-QADuser and Get-MailboxStatistics help

I have the quest active roles cmdlets and MSonline cmdlets in one shell...
Any help would be greatly appreciated

I seem to get the first two columns, DisplayName and SamAccountName but not the crucial piece, LastLogonTime

Get-QADUser jones| Select DisplayName,SamAccountName,@{n="LastLogontime";e={(Get-MailboxStatistics $_.Identity).LastLogontime}} | Export-CSV "c:\scripts\jones-2015-2.csv"

Open in new window

Thank you!
K BAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

K BAuthor Commented:
Came up with this:

Get-QADUser -SizeLimit 0 -LdapFilter "(displayname=a*)(targetAddress=*)" | select DisplayName ,SamAccountName , AccountIsDisabled, @{n = "LastLogontime" ;e= {( Get-MailboxStatistics $_.Name).LastLogontime}} | Export-Csv "C:\scripts\LL-A.csv" -NoTypeInformation

Open in new window

Vasil Michev (MVP)Commented:
You need remote EO PowerShell, not the MSOnline cmdlets.
K BAuthor Commented:
hmm.  What is the command for that..this is what I typically use:
(I supposed this is to both, correct?)

$cred = Get-Credential ""
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri -Credential $Cred -Authentication Basic -AllowRedirection
Import-PSSession $Session

Import-Module MSonline
Connect-MsolService -credential $cred

Open in new window

Virus Depot: Cyber Crime Becomes Big Business

The rising threat of malware-as-a-service is not one to be overlooked. Malware-as-a-service is growing and easily purchased from a full-service cyber-criminal store in a “Virus Depot” fashion. View our webinar recording to learn how to best defend against these attacks!

K BAuthor Commented:

I am trying to incorporate anything that might indicate an issue with off-boarding at this company.  It seems somehow FIM is removing the users license when terminated but this is what is left:

For Example this is a terminated user that is not in the recyclebin:

IsInactiveMailbox                      : False
IsMailboxEnabled                       : True
IsValid                                : True
msExchRecipientDisplayType                            : -2147483642
msExchRecipientTypeDetails                            : 2147483648
msExchRemoteRecipientType                             : 4

What else would I need to gather to insure that the AD object is disabled and that there is no confusion that a mailbox exists in the cloud or (on-premise for that matter).

This is the code I am using (what else should I gather?
Get-QADUser -IncludeAllProperties -SizeLimit 0 -LdapFilter "(&(targetAddress=*)(|(displayname=b*)))" | select DisplayName, msExchRecipientDisplayType, msExchRecipientTypeDetails, msExchRemoteRecipientType, SamAccountName, AccountIsDisabled, @{n = "LastLogontime" ;e= {( Get-MailboxStatistics $_.Name).LastLogontime}} | Export-Csv "C:\scripts\LL-B_C_D.csv"

Open in new window

Vasil Michev (MVP)Commented:
Nah, that looks fine. So just make sure that Get-MailboxStatistics accepts the parameter you are passing from Get-QADUser. Something like the primarySMTP or mail/WindowsEmailaddress should work.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Guy LidbetterCommented:
Hi KB..  the field you need for last logon is "lastLogonTimeStamp".

Lastlogon is saved on whichever DC processes your log on and is not replicated.
LastLogonTimeStamp was introduced for the sole purpose of finding inactive accounts, this field is replicated, by default between 9 and 14 days. But will serve your purpose.

You also need to format it into a readable format for your csv... so replace the Latlogon in your select with this....


Open in new window

Guy LidbetterCommented:
Oh right... last logon for the mailbox... lol - should've read it properly the first time....
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.