I would like the powershell script to generate new log file with the same name and copy old log file to new file with new name if that log file will exceed certain size, like for example log.1 file extension.
I implemented basic Add-Content command with file directory as a variable:
$logmsg = $date + " " + $status.ToString() + " " + $item + " " + $perf + " " + $output
Add-Content D:\...\..._log.txt -Value $logmsg
I don't actually need to script to create more log files like for example log.2, log.3 and etc. I just need to keep old logs in this log.1 file and if the size of original log file will exceed again, log.1 file can be overwritten.
Couldn't find any method for PS scripting specifically.