User last logon details

Hi guys,

Recently, i was asked to collect the user last logon timestamp by manager.
There are bunch of orphaned severs in our QA, we want to remove those from our inventory and delete the permanently.
before that we want to confirm the server are not used by any users. we would like take a report of who and when the user used them lastly.

if the sever not being used by anyone for two month, we are planning to remove. where and how to get the details?

pls assist us.
Balakrishnan PWintel AdministratorAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Tahir QureshiSystem AnalystCommented:
someone has asked this question on Microsoft it has been answered.

I think this is the best way because AD by default does not track which user has login to which computer

https://social.technet.microsoft.com/Forums/windows/en-US/c61dc944-6c40-4ab8-93f8-8c345c37b0d4/last-time-a-specific-user-account-logged-onto-a-specific-computer?forum=winserverpowershell

Import-CSV "C:\My Data\2010\Scripts\input.csv" | % { 

    $Computer = $_.ComputerName

	$ppath1 = "$compuer\c$\Documents and Settings"

	$ppath2 = "$computer\c$\Users"

	$profileaccess1 = Test-Path \\$ppath1

	$profileaccess2 = Test-Path \\$ppath2

			

        If ($profileacces1 -eq "TRUE")

		{

			$compOS = get-wmiobject Win32_OperatingSystem -comp $computer 

			$compOSF = $compOS.Caption

			$compSP = get-wmiobject Win32_OperatingSystem -comp $computer

			$compSPF = $compSP.ServicePackMajorVersion

			$profileNames = get-item "\\$ppath1\*" 

			foreach ($profilename in $profilenames) 

				{	

				$accountName = (get-item $profilename).PSChildName 

				$lastaccesstime = (get-item $profilename).LastAccessTime | 	get-date  –f "MM/dd/yyyy"

				"$Computer,$AccountName,$LastAccesstime,$compOSF,$compSPF" | Out-File $UserInfoFile -encoding ASCII -append

				write-host -fore Green "`t$Computer`t`t$AccountName`t`t$LastAccesstime`t`t$CompOSF`t`t$CompSPF"

				write-host -fore Blue "`t--------------------------------------------------------------------------------------------------"

				}

		}

		ElseIf ($profileaccess2 -eq "TRUE")

		{

			$compOS = get-wmiobject Win32_OperatingSystem -comp $computer 

			$compOSF = $compOS.Caption

			$compSP = get-wmiobject Win32_OperatingSystem -comp $computer

			$compSPF = $compSP.ServicePackMajorVersion

			$profileNames = get-item "\\$ppath2\*" 

			foreach ($profilename in $profilenames) 

				{	

				$accountName = (get-item $profilename).PSChildName 

				$lastaccesstime = (get-item $profilename).LastAccessTime | 	get-date  –f "MM/dd/yyyy"

				"$Computer,$AccountName,$LastAccesstime,$compOSF,$compSPF" | Out-File $UserInfoFile -encoding ASCII -append

				write-host -fore Green "`t$Computer`t`t$AccountName`t`t$LastAccesstime`t`t$CompOSF`t`t$CompSPF"

				write-host -fore Blue "`t--------------------------------------------------------------------------------------------------"

				}

		}

		Else 

		{

			Write-Host -fore Red "Can't access Computer -> $computer"

			"$Computer" | Out-File FailedComputers_File -encoding ASCII -append

		}

	}

Open in new window

Naveen SharmaCommented:
Did you enable the audit policy for user accounts? If you did, you could get the event logs in the event viewer, then you could filter out the related information. This article will help you to audit the successful or failed logon and logoff attempts in the network using the audit policies: https://www.lepide.com/blog/audit-successful-logon-logoff-and-failed-logons-in-activedirectory/

How to Detect Last Logon Date and Time for all Active Directory Users:
https://www.lepide.com/how-to/track-last-logon-date-and-time-for-active-directory-users.html

Have a look at LepideAuditor for Active Directory which gives you detailed information about all Active Directory activities like; who did what and where including reports on last logon time for users.
Balakrishnan PWintel AdministratorAuthor Commented:
thanks to the response's

the scenario is users are on the domain using different servers very often. but we want to see the timestamp from some particular servers (nearly 100), because those are going to be decommissioned soon.
if any chance users asked about the server, after shutting down we can give the proper answer. that they were not logged in to the severs last 2 month.

is there any chance to get the details from each servers?
IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

Naveen SharmaCommented:
By checking the logs. Refer to this thread.

Also, you can use the query user command:
https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-xp/bb490801(v=technet.10)
Yadhu GiriCommented:
If you have SIEM tool like Splunk, You can Index data for Login Audit Logs on 100 Servers. you will get relative Data based on Login Attempts you Later you can take your decision!!!!

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Sara TeasdaleCommented:
You can also use Dsquery or VBscript to check the last logon timestamp.

Dsquery * domainroot -filter "(&(objectCategory=Person)(objectClass=User)(samaccountname=MyName))"  –attr name lastLogonTimeStamp 

Open in new window


 Determine Last Logon Time for a User

http://gallery.technet.microsoft.com/scriptcenter/760c81d2-51c5-4fb1-909f-255949056308

Active Directory User Last Logon

http://gallery.technet.microsoft.com/scriptcenter/1596233c-2f4e-40a5-83cf-4d3265b01d26

https://community.spiceworks.com/how_to/135446-how-to-find-last-logon-time-for-users-in-active-directory

https://www.manageengine.com/products/free-windows-active-directory-tools/free-windows-last-logon-reporter.html
Balakrishnan PWintel AdministratorAuthor Commented:
We pulled the details from splunk and few servers not enabled with audit logs. so we taken the user profile modified time as last login.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
auditing

From novice to tech pro — start learning today.