Hello @tj_zero !
Welcome to Microsoft QnA!
Please try :
# Clean Recent Items
$recent = [System.IO.Path]::Combine($env:APPDATA, 'Microsoft\Windows\Recent')
Remove-Item "$recent*" -Force
# Clean Temp Directory
$temp = $env:TEMP
Remove-Item "$temp*" -Force
# Clear Event Logs (requires elevated privileges)
Get-EventLog -LogName * | ForEach { Clear-EventLog -LogName $_.Log }
# Additional cleanup can be added as needed
Next
Create a Task with Highest Privileges to run the script on user logon!
You might need to run this line also once:
- Open PowerShell as an Administrator.
- Run
Set-ExecutionPolicy RemoteSigned
.
I hope this helps!
Kindly set the answer as accepted and upvote or post your feedback !
Regards