Jump to content
Sign in to follow this  

Using SCCM WebServices and AutoIT

Recommended Posts

Trying to create a script to pull information from a well known SCCM(ConfigMgr 2007) web service.  Web Service works great however the script, not so much.  I have started with just a little script to find the computer information for a specific computer.  I believe if I can get this one working, using the other available functions should be a simple replacement.  However I continue to receive a -1 for reading the data from the XML file that is generated with this service.

#cs ----------------------------------------------------------------------------

 AutoIt Version:
 Author:         myName

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------
#Include <_XMLDomWrapper.au3>
#include <Array.au3>

;~ ; Script Start - Add your code below here

$sSiteCode = "001"
$sCompName = "compname"
$sHostName = "http://hostname.com"

$datafile = "received.xml"

$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
$oHTTP.Open("GET",$sHostName & "/sms_osd/sccm.asmx/SearchComputerByName?SearchString=" & $sCompName & "&SiteCode=" & $sSiteCode, False)

$oReceived = $oHTTP.ResponseText
MsgBox(1, "text", $oReceived)
$oStatusCode = $oHTTP.Status

If $oStatusCode == 200 then
 $file = FileOpen("Received.xml", 2) ; The value of 2 overwrites the file if it already exists
 FileWrite($file, $oReceived)

If FileExists($datafile) Then

    $ret = _XMLFileOpen($datafile)

    MsgBox(1,"File Open", $ret)
        if $ret = 1 then
            MsgBox(0, "Open File Correctly?", "Yes")
            MsgBox(48, "Open File Correctly?", "NO")
            MsgBox(48,"File Open Error!!", @error)
    $sADSiteName = _XMLGetValue("Resource/ADSiteName")
    $sADSiteName2 = _XMLGetValue("/Resource/ADSiteName")
    $sName = _XMLGetValue("/Resource/Name")
    $sNetbiosName = _XMLGetValue("/Resource/NetbiosName")
    $sObsolete = _XMLGetValue("/Resource/Obsolete")
    $sOperatingSystemNameandVersion = _XMLGetValue("/Resource/OperatingSystemNameandVersion")
    $sResourceID = _XMLGetValue("/Resource/ResourceID")
    $sSMSUniqueIdentifier = _XMLGetValue("/Resource/SMSUniqueIdentifier")

;~          _ArrayDisplay($node)
        MsgBox(4096, $sADSiteName[0], $sADSiteName[1])
        MsgBox(4096, $sName[0], $sName[1])
        MsgBox(4096, $sNetbiosName[0], $sNetbiosName[1])
        MsgBox(4096, $sObsolete[0], $sObsolete[1])
        MsgBox(4096, $sOperatingSystemNameandVersion[0], $sOperatingSystemNameandVersion[1])
        MsgBox(4096, $sResourceID[0], $sResourceID[1])
        MsgBox(4096, $sSMSUniqueIdentifier[0], $sSMSUniqueIdentifier[1])
        MsgBox(4096, "Error", _XMLError ())

XML that is generated by using IE to the webservice

<?xml version="1.0" encoding="utf-8"?>
<ArrayOfResource xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://maikkoster.com/Deployment">
    <OperatingSystemNameandVersion>Microsoft Windows NT Workstation 6.1</OperatingSystemNameandVersion>

Share this post

Link to post
Share on other sites

Hi, hoopjunkie, welcome to the forum. You might check out the SCCM script in my signature. It has a number of functions that show connecting directly to an SCCM 2007 db and querying for information, as well as adding to and removing from collections. Might point you in the right direction.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...