difficulties working with powershell Invoke-SQLCmd
So it turns out that the get-help invoke-sqlcmd -example shows the array variable as using 'dbname="MyDatabase"' as the syntax.  However this gives the error above but if you swap the quote positions such that the variable uses "dbname='MyDatabase'" then the script works.