Solved

Get Computer Information from SCCM Databse

Posted on 2014-10-27
9
153 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 47

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 47

Expert Comment

by:Vitor Montalvão
ID: 40406605
There are few code examples in the sub articles. Doesn't seems so hard.
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
LVL 1

Author Comment

by:AnthonySmithMCP
ID: 40406694
I can't get this to work..
0
 
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 47

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Server 2012 - Merge Replication Issue 1 22
Tsql query 6 22
Help in Bulk Insert 9 35
Insert query into temp tables using Coldfusion 3 21
The password reset disk is often mentioned as the best solution to deal with the lost Windows password problem. In Windows 2008, 7, Vista and XP, a password reset disk can be easily created. But besides Windows 7/Vista/XP, Windows Server 2008 and ot…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
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.
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…

810 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