Get the last time a user logged into the domain


DOES THE GUI DO ANYTHING ANYMORE?!

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 = “domain.com\” + $username

get-QADComputer -searchRoot ‘domain.com/domain 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.

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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