We help IT Professionals succeed at work.

How do I convert this WMI code into VB.net?

I have a short bit of code which I really need to convert into .net. All it does is to find the site code of an SCCM server. Can anyone suggest how I might convert this into VB.Net?
Thanks

Simon
set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
set objSWbemServices= objSWbemLocator.ConnectServer("SMS_SITE_SERVER", "root\sms")
Set ProviderLoc = objSWbemServices.InstancesOf("SMS_ProviderLocation")
 
For Each Location In ProviderLoc
        If Location.ProviderForLocalSite = True Then MsgBox Location.SiteCode
Next

Open in new window

Comment
Watch Question

I have but unfortunately was unable to create the code I wanted. For some reason the SMS_ProviderLocation class wouldn't show in the query tab despite showing under the browse namespaces tab. Without it showing in the query tab it won't auto create it. I also tried entering it manually to no avail.
Actually this was easier to fix than I thought. I just needed to add a reference to the Microsoft WMI Scripting v.1.2 Library and it worked fine, give or take a few minor tweaks.