I did this one last week and just forgot to blog it.
This one's on moving user DB files, though the process works just fine with tempdb and msdb.
Now, there at the end when I take the DB offline using code and then online using the GUI, I just brainfarted, so I don't wanna get any email telling me that I can bring a
DB back online with this:
ALTER DATABASE DBName
I'm well aware.