Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Last Folder or doc accessed on the server share

Status
Not open for further replies.

SmartAcer

IS-IT--Management
Aug 26, 2016
1
0
0
ZA
Good Day

I need help with extracting information regarding server share on which I need to few the last accessed folder and doc. I have a script written in PowerShell the problem is I cannot get the output

Get-ChildItem -Recurse "C:\Users\ProfileUser\Desktop\Users.ps1" | ?{ $_.PSIsContainer } | Select-Object FullName,lastwritetime | Out-File 'C:\Users\ProfileUser\Desktop\Test.log'

I'm not sure what's wrong. Thank u
 

Code:
Get-ChildItem -Recurse [COLOR=#EF2929]"C:\Users\ProfileUser\Desktop\Users.ps1"[/color] | [COLOR=#3465A4]?{ $_.PSIsContainer[/color] } | Select-Object FullName,lastwritetime | Out-File 'C:\Users\ProfileUser\Desktop\Test.log'

You are using a file "Users.ps1" as the start of your search, yet filtering for directories. That doesn't work.

Try this to see if you get anything:

Code:
Get-ChildItem -Recurse [COLOR=#EF2929]"C:\Users\ProfileUser"[/color] | Select-Object FullName,LastWriteTime | Out-File 'C:\Users\ProfileUser\Desktop\Test.log'

You could go one step further and sort it by the LastWriteTime:

Code:
$search = Get-ChildItem -Recurse [COLOR=#EF2929]"C:\Users\ProfileUser"[/color] | Select-Object FullName,LastWriteTime
$search = $search | sort LastWriteTime -Descending
$search | Out-File 'C:\Users\ProfileUser\Desktop\Test.log'




Light travels faster than sound. That's why some people appear bright until you hear them speak.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top