• Usually, we backup all databases with a script. Restore is usually per database (as on need). Why do you want to restore all databases? How many databases you need to restore with this script?

    Copying from blogs & running it blindly on PROD server is very dangerous. Test your scripts on Test Server first.