The script is available for download from https://gallery.technet.microsoft.com//How-to-delete-SQL-Server-4d0d41d7. You can also use Microsoft Script Browser for Windows PowerShell ISE to download the sample with one button click from within your scripting environment.
This PowerShell script will demonstrate how to delete all the files older than a specified date with the extension of '.bak'. With the parameters path, file extension and days provided, the script will delete the files (if any) and give information for reference.
As some people asked how to delete backup files older than a specified date, we provide this script to help demo how to achieve it by using Remove-Item. However, this script will delete all the files with '.bak' and meet the date requirement without checking if they are real SQL Server backup files.
You can find more All-In-One Script Framework script samples at https://aka.ms/onescriptingallery