Get the last time a user logged into the domain


Here’s a handy little script that you need to use Quest ActiveRoles or PowerGUI for. If you aren’t using PowerGUI yet … maybe think about checking it out..

$username = read-host -prompt “Enter the user ID to check last logon for:”

$account = “\” + $username

get-QADComputer -searchRoot ‘ controllers’ | Select-Object Name,@{Name=”Last Logon”; Expression={%{ get-QADUser $account -Service $_.Name} | %{$_.DirectoryEntry.lastLogon} | convert-QADAttributeValue -outputTypeName ‘DateTime’}}

That pretty much does it. What could you use this for? Oh… I dunno. Like maybe a user with two accounts who swears they are using the right one and they aren’t.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s