Solved

Get Computer Information from SCCM Databse

Posted on 2014-10-27
9
154 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 48

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 48

Expert Comment

by:Vitor Montalvão
ID: 40406605
There are few code examples in the sub articles. Doesn't seems so hard.
0
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
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 48

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

INTRODUCTION The purpose of this document is to demonstrate the Installation and configuration of the Data Protection Manager product. Note that this demonstration was prepared on the basis of Windows OS is 2008 R2 and DPM 2010. DATA PROTECTI…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

840 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