Ran into an issue while writing a script to gather database properties via smo and one that I want is database size. I wrote the script and started testing it and my values were all wrong and the same for all databases in the instance. I did a few things trying to figure out what I was doing wrong and I even pinged Aaron Nelson (Blog | Twitter) about the issue and he was nice enough to help me out and take a look at the issue. He looked at the code and my results and had me check in SSMS that the results were correct. After I checked in SSMS and verified that the values were in fact correct he had me try getting the data using the provider, explained here in his Hey Scripting Guy article. I did that and now the data was correct. That is strange and I started thinking and I had not attempted to run this script from another host. I did that and I saw that, using SMO, the data came back was correct. Now I knew it was something with my machine but what?
I started searching and I found it. This is a bug in SQL Server 2008 SP1. I have a SQL 2008 instance running on my machine that I use for testing and developing and I had recently applied SP1. Here is a link to the article about the bug. http://support.microsoft.com/kb/972207/Updated. I downloaded and applied CU3 for 2008 SP1 and now I am getting the correct results. What a pain. I am just glad that it is working again and it was not my code.
Hope this helps