Wednesday, July 23, 2008

A small bug in SMO

I recently encountered what appears to be a small bug in SMO:

When accessing the SqlServer.Management.Smo.Wmi.ManagedComputer namespace using a 32bit application (ie. Powershell.exe) from a 64-bit platform (HW & OS), SMO won't return anything for the "ServerInstances" property. If a 64bit application is used everything works just fine.

Try the following script from the 32, and 64 bit versions of PowerShell (repalce MyServer with the name of your SQL server):

32bit: %SystemRoot%\sysWOW64\WindowsPowerShell\v1.0\powershell.exe
- or -
64bit: %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe

[reflection.assembly]::Load("Microsoft.SqlServer.Smo, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91")
$mc = new-object "Microsoft.SqlServer.Management.Smo.Wmi.ManagedComputer" MyServer
$mc

Result when working the correct way:

ConnectionSettings : Microsoft.SqlServer.Management.Smo.Wmi.WmiConnectionInfo
Services : {MSFTESQL$SQL01, MSFTESQL$SQL02, MSFTESQL$SQL03, MSFTESQL$SQL04...}
ClientProtocols : {np, sm, tcp, via}
ServerInstances : {SQL01, SQL02, SQL03, SQL04...}
ServerAliases : {}
Urn : ManagedComputer[@Name='MyServer']
Name : MyServer
Properties : {}
UserData :
State : Existing

Result when NOT working working the correct way:

ConnectionSettings : Microsoft.SqlServer.Management.Smo.Wmi.WmiConnectionInfo
Services : {MSFTESQL$SQL01, MSFTESQL$SQL02, MSFTESQL$SQL03, MSFTESQL$SQL04...}
ClientProtocols : {np, sm, tcp, via}
ServerInstances : {}
ServerAliases : {}
Urn : ManagedComputer[@Name='MyServer']
Name : MyServer
Properties : {}
UserData :
State : Existing

14 comments:

Conry Lavis said...

Nice article. keep it up.
Buy Pinterest Followers

Keerthi said...

Excellent and very cool idea and the subject at the top of magnificence and I am happy to this post..Interesting post! Thanks for writing it. What's wrong with this kind of post exactly? It follows your previous guideline for post length as well as clarity..

SEO Company in Chennai | Digital Marketing Company in Chennai

Navya Kumar said...

Usually I do not read post on blogs, but I would like to say that this write-up very forced me to try and do it! Your writing style has been surprised me. Great work admin.Keep update more blog.

SEO Company in Chennai

Dipika T said...

Great written and include almost all important info. Thanks for sharing

Web Design Company in Belgaum | web development company in Belgaum | IT companies in Belgaum | Web Design Companies in Belgaum | Software Companies in Belgaum

Sindhuja Ravi said...

Superb. I really enjoyed very much with this article here. Really it is an amazing article I had ever read. I hope it will help a lot for all. Thank you so much for this amazing posts and please keep update like this excellent article.thank you for sharing such a great blog with us. expecting for your..
SEO Company in India

Radley Co Tad said...

An important building block of SEO is to develop your website which can be easily understandable for both Online Visitors (most important) and search engine robots. In the current digital age, seo is important for your online success means to generate leads.

SEO Services in IndiaSEO Company in India SEO Company in India SEO Services in India

SEO Company in India SEO Services in India

tessa tessa said...

Wonderful bloggers like yourself who would positively reply encouraged me to be more open and engaging in commenting. So know it's helpful..

SEO Company in Chennai

rupali verma said...

I am very inspired to read your post about digital marketing, it will be very helpful for all new learner to learn Digital marketing courses in pune.

education information said...

I am very inspired to read your post about digital marketing, it will be very helpful for all new learner to learn Digital marketing courses in pune.

Jessica George said...

Being new to the blogging world I feel like there is still so much to learn. Your tips helped to clarify a few things for me as well as giving..

SEO Company in Chennai

alliance it said...

I found this cool post here and enjoyed reading your articles, thank you. This is really a helpful post.

smo company in delhi
smo Services in India

janaki sree ram said...

Nice information thanks for sharing
Best SEO consultant in Chennai

webwing said...

"Really nice and awesome info "!!Thank you
affordable search engine optimization company | professional custom website design company

Karnati.Balachandra said...

It’s grate too good information thank you so much for sharing. Best SEO consultant in Chennai