Powershell/CMD continuous ping to file which is overwritten after X days

I’ve found a lot of examples of continuous ping and saving output to a file. But what i was hoping to find was how do I have the script rewrite the output file after every 7 days, thereby eliminating the need for intervention.

Purpose: The idea is to run this script from a windows server and have it ping 8.8.8.8 every 30 seconds to check internet connectivity and log it to a file which is stored for 7 days and on the 8th day the script should start rewriting from line 1.

I only have the basic script:

Powershell:

ping -t 8.8.8.8|Foreach{"{0} - {1}" -f (Get-Date),$_} > c:pingtest.txt

CMD:

ping 8.8.8.8 –t |cmd /q /v /c "(pause&pause)>nul & for /l %a in () do (set /p "data=" && echo(!date! !time! !data!)&ping -n 2 8.8.8.8>nul" >>"C:pingTEST.txt"