Tuesday, 10 September 2013

Powershell: Sorting and display the most recent duplicate in a custom object (by username)

Powershell: Sorting and display the most recent duplicate in a custom
object (by username)

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
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 :

No comments:

Post a Comment