Solved

Get Computer Information from SCCM Databse

Posted on 2014-10-27
9
149 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 46

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 46

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
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
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 46

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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
When you upgrade from Windows 8 to 8.1 or to Windows 10 or if you are like me you are on the Insider Program you may find yourself with many 450MB recovery partitions.  With a traditional disk that may not be a problem but with relatively smaller SS…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

895 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

11 Experts available now in Live!

Get 1:1 Help Now