• I may not be helping fix this particular problem, but I had a look at the PS and the embedded sql and have difficulty reading it inside the PS.

    How about using the built in backup and restore CmdLet instead of invoking SQL from Powershell?

    This may simplify the script and make it easier to debug.

    Restore-SqlDatabase -ServerInstance MySQL -Database AdventureWorks `-BackupFile

    "\\Myserver\MyShareFolderWithRights\Backup\AdventureWorks12Nov20151012AM.bak"

    -ReplaceDatabase

    Catch-all queries done right [/url]
    Gail Shaw's Performance Blog[/url]