Skip to content

Instantly share code, notes, and snippets.

@martin9700
Last active October 12, 2015 01:15
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save martin9700/b22c566b2bc4c5c7c997 to your computer and use it in GitHub Desktop.
$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