Key takeaways -
How the connection to the SQL server is created.
1.Load SQL SMO assemblies.
Test as you go: At this point, executing "write-host $databases" should give you something like this: [master] [model] [msdb] [tempdb] [testdb1] [testdb2] etc...
Backing up all non-system databases.
1.Differentiating between system/non system databases.
» Executing write-host $databases.issystemobject should give us an output such as: True True True True False
» Now we know that we can differentiate between system databases and nonsystem databases.
2.Run "something" for each non system database.
Take note to the TRY/CATCH and the exception message on the CATCH. This is an error handler incase the database fails to backup. On failure, the exception message will be displayed in the console output.
The best way to learn, download the script and play!