Solved

Get Computer Information from SCCM Databse

Posted on 2014-10-27
9
146 Views
Last Modified: 2014-12-10
Good Morning,

I'm trying to find out the next steps to get computer information from the SCCM database. I have the steps to make the connection then grab the computer but can't seem to figure out how to get the computer attributes. Please help. Here's my code below.

        Dim strComputer = "ComputerConnectingto"
        Dim strSMSServer = "SCCMServer"
        Dim strSMSSiteCode = "SITECODE"
        Dim strUserName = "username"
        Dim strPassword = "password"
        Dim TSystem

        Try

            Dim lLocator = CreateObject("WbemScripting.SWbemLocator")
            Dim gService = lLocator.ConnectServer(strSMSServer, "root\sms\site_" & strSMSSiteCode, strUserName, strPassword)
            TSystem = gService.ExecQuery("SELECT * from SMS_R_System where NetbiosName = '" & strComputer & "'")


        Catch ex As Exception
            MsgBox("Could not connect to SCCM Server - ErrorDescription:" & Err.Description)
            End

        End Try

Open in new window

0
Comment
Question by:AnthonySmithMCP
  • 6
  • 3
9 Comments
 
LVL 45

Expert Comment

by:Vitor Montalvão
ID: 40406557
There's a complete WMI object for that. Check the MSDN.
0
 
LVL 1

Author Comment

by:AnthonySmithMCP
ID: 40406576
I'm looking at it now..  But I'm not an expert with coding..
0
 
LVL 45

Expert Comment

by:Vitor Montalvão
ID: 40406605
There are few code examples in the sub articles. Doesn't seems so hard.
0
 
LVL 1

Author Comment

by:AnthonySmithMCP
ID: 40406694
I can't get this to work..
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 1

Author Comment

by:AnthonySmithMCP
ID: 40406700
Here's what I have.. Its not displaying the system information.. It's just showing {0}

        Dim options As ConnectionOptions
        options = New ConnectionOptions()
        options.Username = "domain\username"
        options.Password = "password"

        Dim scope As ManagementScope
        scope = New ManagementScope("\\Computername\root\cimv2", options)
        scope.Connect()

        ' Query system for Operating System information
        Dim query As ObjectQuery
        query = New ObjectQuery("SELECT * FROM Win32_OperatingSystem")
        Dim searcher As ManagementObjectSearcher
        searcher = New ManagementObjectSearcher(scope, query)

        Dim queryCollection As ManagementObjectCollection
        queryCollection = searcher.Get()

        Dim m As ManagementObject
        For Each m In queryCollection
            ' Display the remote computer information
            MessageBox.Show("Windows Directory : {0}", m("WindowsDirectory"))
            MessageBox.Show("Operating System: {0}", m("Caption"))
            MessageBox.Show("Version: {0}", m("Version"))
            MessageBox.Show("Manufacturer : {0}", m("Manufacturer"))
        Next

        Return

Open in new window

0
 
LVL 1

Author Comment

by:AnthonySmithMCP
ID: 40407013
Anyone?
0
 
LVL 45

Expert Comment

by:Vitor Montalvão
ID: 40408753
I think the line:
query = New ObjectQuery("SELECT * FROM Win32_OperatingSystem")

should be:
query = New ObjectQuery("SELECT * FROM SMS_Client")
0
 
LVL 1

Accepted Solution

by:
AnthonySmithMCP earned 0 total points
ID: 40413308
I found what i was looking for.

        Dim scope As ManagementScope
        scope = New ManagementScope("\\" & SelectedSystem.Text & "\ROOT\ccm\ClientSDK")

        Try
            scope.Connect()

            'Gets the WMI Value
            Dim query As ObjectQuery
            query = New ObjectQuery("SELECT * FROM CCM_ClientAgentSettings")
            Dim searcher As ManagementObjectSearcher
            searcher = New ManagementObjectSearcher(scope, query)

            Dim queryCollection As ManagementObjectCollection
            queryCollection = searcher.Get()

            Dim m As ManagementObject
            For Each m In queryCollection
                If (m("BrandingTitle")) = "Tony's Network Services" Then
                    ClientInstalled.Text = "Client Installed"
                    ClientInstalled.BackColor = Color.Green
                Else
                    ClientInstalled.Text = "Client NOT Installed"
                    ClientInstalled.BackColor = Color.Red
                End If
            Next

            Return
        Catch ex As Exception
            MessageBox.Show("System is Offline - Can't Detect SCCM Client")
            ClientInstalled.Text = "System Offline"
            ClientInstalled.BackColor = Color.Red
        End Try

Open in new window

0
 
LVL 1

Author Closing Comment

by:AnthonySmithMCP
ID: 40490922
Found answer on my own
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now