Jump to content

System Center Configuration Manager (SCCM) Trigger download


Kovacic
 Share

Recommended Posts

Greetings, I am trying to make a small program that, when launched on a client computer, initiates an SCCM software install. I have done alot of searching and code testing and found the _SCCM UDF does not do what I need, that is more of a server admin tool. 

 

The tool I'm looking to make will launch installs for pre specified software packages that do not require approval in SCCM. I tried using Fiddler to grab the button push string, but it uses session cookies and all types of extra auth strings. Has anyone found a way to do this?

This is my test for connecting to the SCCM Server which does work..

 

#include <Array.au3>
#include <_SCCM.au3>
$oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
$oConfigMgr = ObjCreate("Microsoft.SMS.Client")
If Not @error Then $sServer = $oConfigMgr.GetCurrentManagementPoint
$SCode = "MySite"
$sPC = @ComputerName
Local $oLocator = ObjCreate("WbemScripting.SWbemLocator")
If IsObj($oLocator) Then
    $__goSMS = $oLocator.ConnectServer($sServer, "root\sms\site_CFG")
    If @error Then
        MsgBox(0, "Debug", "Error")
    Else
        MsgBox(0, "Debug", "It worked.")
    EndIf
EndIf
Func MyErrFunc()
    MsgBox(0, "AutoItCOM", "We intercepted a COM Error !" & @CRLF & @CRLF & _
            "err.description is: " & @TAB & $oMyError.description & @CRLF & _
            "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _
            "err.number is: " & @TAB & Hex($oMyError.number, 8) & @CRLF & _
            "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _
            "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _
            "err.source is: " & @TAB & $oMyError.source & @CRLF & _
            "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _
            "err.helpcontext is: " & @TAB & $oMyError.helpcontext _
            )
    Local $err = $oMyError.number
    If $err = 0 Then $err = -1
    $g_eventerror = $err ; to check for after this function returns
EndFunc   ;==>MyErrFunc

Thanks!!!!!!!!

 

 

C0d3 is P0etry( ͡° ͜ʖ ͡°)

Link to comment
Share on other sites

  • Moderators

@Kovacic, you are right my SCCM UDF won't do what you're after. My question would be why you would want to initiate a push from the client rather than creating a collection and putting that machine in the collection, then using the Config Manager to pull it down. Just curious what the driver is, as this seems completely backward from normal use; In all my time administering SCCM and SMS I've never come across a need to do it this way. Are you perhaps meaning a package that has been set to Available, and not Required?

"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!

Link to comment
Share on other sites

You are absolutely correct, it is contrary to best practice.. However I am making a post profiler for end users, so what it will ultimately do is, when we run the backup on their old computer, it will detect what software they have installed and make a CSV of that list (that part is already done). The restore (post profile) portion will look at that list, and only install software they already have, even though they may have been approved for other software. I have this scripted out for the most part in pieces because only I was using it, but the company I work for says they have a need for me to beautify it and package it for release. The ultimate goal is to have this as simple as possible for an end user to operate with very few options. I don't want to send them to the SCCM web console to choose their software, I just want to auto push the stuff they already had.. That's what I am hoping to do anyways...

 

Thanks!!

C0d3 is P0etry( ͡° ͜ʖ ͡°)

Link to comment
Share on other sites

Have you tried Powershell?  I have not attempted this specific task but i think the mechanisms are there.

 

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

  • Moderators

In re-reading your explanation, I think you could do something with the SCCM UDF: If you used _SCCM_ListCollectionsForPC to gather all the collections they are in, you could then use _SCCM_AddToCollection to put the new machine in those same collections.

I guess I don't understand the "install only the software they already have, even if they have been approved for other software" bit. It sounds like, rather than a list of collections on the old machine, you want to pull a list of applications installed via WMI, and only put the new machine into those collections. Is that closer to what you're thinking?

"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!

Link to comment
Share on other sites

In re-reading your explanation, I think you could do something with the SCCM UDF: If you used _SCCM_ListCollectionsForPC to gather all the collections they are in, you could then use _SCCM_AddToCollection to put the new machine in those same collections.

I guess I don't understand the "install only the software they already have, even if they have been approved for other software" bit. It sounds like, rather than a list of collections on the old machine, you want to pull a list of applications installed via WMI, and only put the new machine into those collections. Is that closer to what you're thinking?

Yes, thats about right, only WMI is kind of slow, so I used this:

Func _InstalledSoftware($sComputerName = @ComputerName) 
    $iInstalledAppsCount = 1
    $sInstalledAppsLog =  $ProfilePath & "\Installed Software x64.csv"
    $hInstalledAppsLogFile = FileOpen($sInstalledAppsLog, 1) ;Output to a CSV file.
    While 1
        $sSubKey = RegEnumKey("\\" & $sComputerName & "\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", $iInstalledAppsCount)
        Switch @error
            Case 1, 2, 3
                ;
            Case -1
                ExitLoop
        EndSwitch
        $sDisplayName = RegRead("\\" & $sComputerName & "\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & $sSubKey, "DisplayName")
        $sDisplayVersion = RegRead("\\" & $sComputerName & "\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & $sSubKey, "DisplayVersion")
        If $sDisplayName <> "" Then FileWriteLine($hInstalledAppsLogFile, $sDisplayName & "," & $sDisplayVersion)
        $iInstalledAppsCount += 1
    WEnd
    FileClose($hInstalledAppsLogFile)
    Local $aInstalledApps
    _FileReadToArray($sInstalledAppsLog, $aInstalledApps)
;~  _ArrayDisplay($aInstalledApps) ;For Testing.
    _ArraySort($aInstalledApps, 0, 1)
;~  _ArrayDisplay($aInstalledApps) ;For Testing.
    _FileWriteFromArray($sInstalledAppsLog, $aInstalledApps, 1)
    _FileWriteToLine($sInstalledAppsLog, 1, "Program Name, Program Version") ;CSV file column headers.
    Return 1
EndFunc

 

C0d3 is P0etry( ͡° ͜ʖ ͡°)

Link to comment
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
 Share

×
×
  • Create New...