All three have their uses.
I like invoke-sqlcmd
for quick & dirty queries, or queries that already exist in other files (as you can pass in a file parameter). I've never had to deal with the error you had that sparked the question, though.
I use SQLConnection
& SQLCommand
when I need more safety - parameterized queries, for example - or want to maintain a more persistent connection - when I'm running a lot of queries in rapid succession - so that I don't hammer the server with a lot of connections in a short period of time.
SMO I haven't really used, but I would reserve that for managing at the "system" level - jobs, backups, etc. You can do pretty much anything with SMO - Wayne Sheffield had examples of adding & altering tables & stored procedures in his blog last month (I can't link to the posts, as my office firewall blocks it for unknown reasons). I would normally do that through a T-SQL query, but it works both ways, and I'm sure there must be some advantage do doing it with SMO.