SQL Server 2012 Powershell script to generate database with schema and data
I wanted to use Powershell to script a small database so that I can track changes in git. I found the same script you did to use as a starting point:
Automated Script Generation with Powershell and SMO

You can find all of the options for the ScriptingOptions class here: ScriptingOptions Class

You're getting the error because of the now deprecated ScriptTransfer method.

Replace this line

$transfer.ScriptTransfer()


with this

$transfer.EnumScriptTransfer()


and your script should run.