Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
$Users = @{}
ForEach ($User in $AllUsers)
{ If ($Users.ContainsKey($User.SamAccountName))
{ If ($Users[$User.SamAccountName].lastLogon -lt $User.lastLogon)
{ $Users[$User.SamAccountName].lastLogon = $User.lastLogon
}
}
Else
{ $Users.Add($User.SamAccountName,($User | Select SamAccountName,Name,lastLogon))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment