Solved

Get Computer Information from SCCM Databse

Posted on 2014-10-27
9
158 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
9 Comments
 
LVL 49

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 49

Expert Comment

by:Vitor Montalvão
ID: 40406605
There are few code examples in the sub articles. Doesn't seems so hard.
0
Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

 
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 49

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
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…
Via a live example, show how to shrink a transaction log file down to a reasonable size.
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…

726 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