Minor fix to the script - because of the $date name of the variable it was not possible to deserialize this script as sitecore replaced $date with the current date. Also minor fix to script logic - changed the $SitecoreDataFolder\logs to $SitecoreLogFolder\ as logs don't necessarily have to be in the "logs" subfolder of the Data folder but the location can be changed in configuration files.