I currently have a simple batch file that deletes unnecessary cached data at log out for multiple workstations set as a GPO. I am trying to amend it to report back to me in one text doc every time this runs on the various workstations with the date as the name of the text doc and the name of the workstation and the user it was run for as the contents, (examples below).
Current Script Example:
Echo off
Del /f /s /q "C:\User\%username%\AppData\Local\Microsoft\OneNote\16.0\Backup"
Del /f /s /q "C:\User\%username%\AppData\Local\Microsoft\OneNote\16.0\Cache"
Del /f /s /q "C:\Users\%username%\AppData\Roaming\Microsoft\OneNote\16.0"
Requested Output Example:
File name: 20220815.txt
contents:
UserName | Workstation 1 | Time
UserName | Workstation 2 | Time
Etc.
File name: 20220816.txt
contents:
UserName | Workstation 1 | Time
UserName | Workstation 2 | Time
Etc.
Any help would be greatly appreciated.
CodePudding user response:
This comment by Stephan what what I needed. The only thing I changed was
"echo %username% ^| %computername% ^| %time% > file.txt
"
to
"echo %username% ^| %computername% ^| %time%>> file.txt
"
so It can append the existing documents instead of creating a new one for every instance. Thank you!!!!
**
"If you want to delete files, use del *. to create the textile, use echo %username% ^| %computername% ^| %time% > file.txt. To get the filename, use one of the answers to this question (preferably one that does not depend on user settings, as they can be very individual) – Stephan 21 hours ago"
**