Errors occur. (I'm sure that's someone's corollary to Stuff Happens.) Errors occur, and that's why we write error handling code in our applications.
My least favorite time for the occurrance of errors is when I'm doing demos, and that's what happened in a presentation I did at PASS last week. I try to test everything before giving the demos, but every so often something slips through the cracks, and that happened. :-(
Two things that I'd blogged about here (SQL 2008 SMO - Doing a Little Rearranging) came back and bit me, because I'd forgotten about them. In a nutshell, the Backup/Restore objects have been moved to Microsoft.SqlServer.SmoExtended.dll and the WMI objects have been moved to Microsoft.SqlServer.SqlWmiManagement.dll. The appropriate DLL has to be loaded in the PowerShell script before the objects contained in those DLLs can be referenced.
If you download my demo scripts from the PASS website, know that they're configured to be run from a workstation where SQL Server 2008 tools have been installed. They'll work against SQL Server 2000, 2005 and 2008. If you want to use them from a workstation with SQL Server 2005 tools, then delete the lines reference the aforementioned DLLs and they'll run fine.
One other problem occurred with my createdb.ps1 script, which is a condition that's occurred since I started working with SMO from PowerShell. In the Server object there's a collection called Settings. In that collection are properties for DefaultData and DefaultLog. These properties are very convenient for finding where your data and log files are supposed to go when you're adding files to databases.
For some reason, these properties are set to null, or an empty string, when the server is installed. The only way I've found to set them to their proper values is to use the Server Properties dialog in Management Studio, go to the Database Settings page and change them to something very different than what's there, then go back and set them back again. Once that's done the properties return the correct values in PowerShell and the createdb.ps1 script I use in my demos works just fine.
I've updated the slides and demos available for download from the PASS site, so grab those updated files and good luck with your testing.