#Find all the user profiles
$users = Get-ChildItem "C:\Users"
#Loop through each profile hive and pull last access time
foreach($user in $users)
{
$userName = $user.Name
$AccessTime = Get-Item -force “C:\Users\$userName\Downloads” | Select LastWriteTime
$UserProfile = $userName
New-Object -TypeName PSCustomObject -Property @{
Accesstime = $AccessTime.LastWriteTime
Username = $UserProfile
} | Export-Csv -Path C:\temp\profiles3.csv -NoTypeInformation -Append
}