I'm looking for some suggestions/tips on how to sort and display the most recent record in a custom object (by a username). Basically, I am in a situation where I have an ActiveSync report with multiple usernames showing up on the report but I only want the most recent user's device information like device version , last contact time, etc... (See below the custom object's fields)
I've tried the following code but I am not getting the results I am looking for.
$ActiveSyncImport | Group-Object Identity| foreach-object { $_.group | sort-object LastSuccessSync | select -last 1}
Any help would be greatly appreciated
**Update as of 9/10/2013 at 8:40pm MST:
The output I am trying to get is like the following:
DeviceOS DeviceID
-------- --------
ApplDMPFWGAADFHW
Windows Phone7.10.7720 C3F755AAEB6CDE163838A106B00382F8
Android 4.2.2 3939303030303238323236343838
But, when I use my one-line of code I get the same results as my original ActiveSync Information not sorted or grouped.
ActiveSync Information:
RunspaceId : be1d8592-a70a-4322-a146-f6569a067af6
SamAccountName :
FirstSyncTime : 4/8/2013 9:49:31 PM
LastPolicyUpdateTime : 4/8/2013 9:50:41 PM
LastSyncAttemptTime : 9/9/2013 4:06:13 AM
LastSuccessSync : 9/9/2013 4:06:13 AM
DeviceType : iPhone
DeviceID : ApplC39xxxP9DDP7
DeviceUserAgent : Apple-iPhone3C3/1002.329
DeviceWipeSentTime :
DeviceWipeRequestTime :
DeviceWipeAckTime :
LastPingHeartbeat : 900
RecoveryPassword : ********
DeviceModel : iPhone3C3
DeviceImei :
DeviceFriendlyName : Black iPhone 4
DeviceOS : iOS 6.1.3 10B329
DeviceOSLanguage : en
DevicePhoneNumber :
MailboxLogReport :
DeviceEnableOutboundSMS : False
DeviceMobileOperator :
Identity : corp.XXXX.com/NorthAmerica/Users/lastname, firstname/ExchangeActiveSyncDevices/iPhone§ApplC39xxxP9DDP7
Guid : e7712106-3643-XXXX-XXXX-e20fa4376ad9
IsRemoteWipeSupported : True
Status : DeviceOk
StatusNote :
DeviceAccessState : Allowed
DeviceAccessStateReason : Global
DeviceAccessControlRule :
DevicePolicyApplied : Default ActiveSync Policy
DevicePolicyApplicationStatus : AppliedInFull
LastDeviceWipeRequestor :
DeviceActiveSyncVersion : 14.1
NumberOfFoldersSynced : 12
SyncStateUpgradeTime :