As per @ReddyLutonadio', you'll get:
Get-Process |
Where {$_.MainWindowTitle } |
ForEach { Get-ChildItem $_.Path} |
Select Name, LastAccessTime |
Sort LastAccessTime
# Results
<#
Name LastAccessTime
---- --------------
TextInputHost.exe 24-Jul-22 18:48:48
Calculator.exe 24-Jul-22 18:49:11
SystemSettings.exe 24-Jul-22 18:55:28
msedge.exe 24-Jul-22 21:53:50
OUTLOOK.EXE 24-Jul-22 21:53:50
EXCEL.EXE 24-Jul-22 21:53:50
ApplicationFrameHost.exe 24-Jul-22 21:53:50
powershell.exe 24-Jul-22 21:53:50 <--------- Process that ran the command
#>
Refactoring '@ReddyLutonadio' helpful answer, as indicated by 'DrMoishe Pippik' comment, to show what I mean
Eliminate the current process which ran the command.
(Get-Process |
Where { $_.MainWindowTitle } |
ForEach { Get-ChildItem $_.Path} |
Select Name, LastAccessTime |
Sort LastAccessTime) -notmatch [System.Diagnostics.Process]::GetCurrentProcess()
# Results
<#
Name LastAccessTime
---- --------------
TextInputHost.exe 24-Jul-22 18:48:48
Calculator.exe 24-Jul-22 18:49:11
SystemSettings.exe 24-Jul-22 18:55:28
msedge.exe 24-Jul-22 21:54:50
OUTLOOK.EXE 24-Jul-22 21:54:50
EXCEL.EXE 24-Jul-22 21:54:50
powershell.exe 24-Jul-22 21:54:50
ApplicationFrameHost.exe 24-Jul-22 21:54:50
#>
Point of note:
The above response only works when executed from a true PowerShell console instance. It does not work in the PowerShell ISE.
Note:
When using the 'Windows terminal' PScore (psv7...) that filter is not needed as the process is not reported back. You also will get a much longer list.
Note:
In raw PSCore, you still need the filter as shown.
So, the point is, that you need to keep in mind where you are running this in mind as the results will differ.
So, test the command in powershell.exe, powershell_ise.exe, pwsh.exe, and from the 'Windows Terminal', via 'Windows PowerShell and PowerShell Core' to see for yourself what the results will be.
Also, test in VSCode, just to be sure you know what is what.
Update and per your question
Get-Process |
Where { $PSItem.MainWindowTitle } |
ForEach-Object { $PSItem } |
Select ProcessName, Id,
@{Name = 'LastAccessTime';Expression = {(Get-ChildItem $PSItem.Path).LastAccessTime}} |
Sort LastAccessTime
# Results
<#
ProcessName Id LastAccessTime
----------- -- --------------
TextInputHost 14048 25-Jul-22 08:06:59
SystemSettings 7468 25-Jul-22 08:07:18
Calculator 8824 25-Jul-22 08:08:01
msedge 11372 25-Jul-22 10:40:10
OUTLOOK 10988 25-Jul-22 10:40:10
powershell_ise 20524 25-Jul-22 10:40:10
ApplicationFrameHost 7496 25-Jul-22 10:40:10
notepad 4212 25-Jul-22 10:40:10
powershell 17824 25-Jul-22 10:40:11
powershell 21824 25-Jul-22 10:40:11
#>
Get-Process | Where { $_.MainWindowTitle } | ForEach { Get-ChildItem $_.Path} | Select Name, LastAccessTime | Sort LastAccessTime
.