Question WMI queries for SMS (SCCM) information

Pie Captain

Member
Joined
Mar 31, 2010
Messages
14
Location
Bishops Waltham, Hampshire, United Kingdom
Programming Experience
1-3
Hi All,
I'm trying to get the assigned SMS site from a remote machine in VB.net

I can do this in VBS, but i need it in VB.net* (using framework 4.0)

the vbs looks like this:

VB.NET:
Set smsClient = GetObject("winmgmts://" & strComputer & "/root/ccm:SMS_Client")
Set result = smsClient.ExecMethod_("GetAssignedSite")

I've tried the following the variations in VB.net...

VB.NET:
Dim searcher As New ManagementObjectSearcher("//" + ComboBoxMachineName.Text + "/root/ccm:SMS_Client")

Dim searcher As New ManagementObjectSearcher("\\" + ComboBoxMachineName.Text + "\root\ccm:SMS_Client")

Dim searcher As New ManagementObjectSearcher("\\" + ComboBoxMachineName.Text + "\root\ccm:SMS_Client=@")

Dim searcher As New ManagementObjectSearcher("\\" + ComboBoxMachineName.Text + "\root\ccm", "Select * from SMS_Client")
 
 
        For Each queryObj As ManagementObject In searcher.Get()
            LabelWMISMSSite.Text = queryObj("GetAssignedSite")
        Next

but all report that

VB.NET:
LabelWMISMSSite.Text = queryObj("GetAssignedSite")

is an invalid query and several hours of googling have, so far, been fruitless

can anyone point me in the right direction?? (neither the M$ or vanderwoude wmi generators seem to be any help for this one :( )

* i could check this in the registry, but this projeect is more a *learn vb.net project* so i'd rather learn how to do it in VB.

Many thanks
Paul
 
Last edited:

Pie Captain

Member
Joined
Mar 31, 2010
Messages
14
Location
Bishops Waltham, Hampshire, United Kingdom
Programming Experience
1-3
Fixed it... shows how rubbish i am with coding!

This does the trick...

VB.NET:
        Dim smsClient = GetObject("winmgmts://" & ComboBoxMachineName.Text &  /root/ccm:SMS_Client")
        Dim result = smsClient.ExecMethod_("GetAssignedSite")
        LabelWMISMSSite.Text = result.sSiteCode

simple when you know how eh...
 
Top Bottom