Restore-Database doesn't work, because it uses the variable $smo which is not defined

Restore-Database doesn't work, because on line 93 $smo is used instead of $server