Moderators JLogan3o13 Posted October 3, 2014 Moderators Share Posted October 3, 2014 (edited) I am finally back at a customer location where I could work with Microsoft System Center Configuration Manager, and wanted to update the script from >this thread. This time around, rather than a full GUI it is simply a UDF, allowing the user to employ the functions however they would like. This has been tested on 2012 and 2012 R2; unfortunately I no longer have any customers with access to 2007. Currently there are 11 public functions; will continue to update and provide examples as I get a chance. There is also an _SCCM_Constants.au3 that needs to be copied to the Includes directory. Updated 10/14/2014: Added _SCCM_DeletePC function and example Updated 04/12/2015: Added _SCCM_RefreshCollection function and example _SCCM.au3 _SCCM_Constants.au3 Examples: Connect to the SCCM server and return an array of all collections for the site #include <Array.au3> #include <_SCCM.au3> $sServer = "my-sccm" $sCode = "P01" $sPC = "JLVMWIN7x64" $sCollection = "Adobe Acrobat 9 Uninstall" $myResult = _SCCM_Connect($sServer, $sCode) If @error Then ConsoleWrite(@extended & @CRLF) Else _ArrayDisplay($myResult, "All Collections") EndIf Return an array of collections based on a given filter #include <Array.au3> #include <_SCCM.au3> $sServer = "my-sccm" $sCode = "P01" $sPC = "JLVMWIN7x86" _SCCM_Connect($sServer, $sCode) $myResult = _SCCM_FilterColls($sCode, "Application Deployment") If @error Then ConsoleWrite(@extended & @CRLF) Else _ArrayDisplay($myResult, "Collections filtered by user") EndIf Add a single machine to a collection #include <Array.au3> #include <_SCCM.au3> $sServer = "my-sccm" $sCode = "P01" $sPC = "JLVMWIN7x86" $sCollection = "Adobe Acrobat 8 Uninstall" _SCCM_Connect($sServer, $sCode) $myResult = _SCCM_AddToCollection($sPC, $sCollection) If @error Then ConsoleWrite(@error & "|" & @extended & @CRLF) Remove a single machine from a collection #include <Array.au3> #include <_SCCM.au3> $sServer = "my-sccm" $sCode = "P01" $sPC = "JLVMWIN7x86" $sCollection = "Adobe Acrobat 8 Uninstall" _SCCM_Connect($sServer, $sCode) _SCCM_RemoveFromCollection($sPC, $sCollection) If @error Then ConsoleWrite(@error & "|" & @extended & @CRLF) Remove all machines from a collection #include <Array.au3> #include <_SCCM.au3> $sServer = "my-sccm" $sCode = "P01" $sCollection = "Adobe Acrobat 8 Uninstall" _SCCM_Connect($sServer, $sCode) ;===Add several test PCs to the collection _SCCM_AddToCollection("TestPC01", $sCollection) _SCCM_AddToCollection("TestPC02", $sCollection) _SCCM_AddToCollection("TestPC03", $sCollection) ;===Remove all PCs from the collection _SCCM_RemoveAllPCsFromCollection($sCollection) If @error Then ConsoleWrite(@error & "|" & @extended & @CRLF) Return an array of all collections for a specified PC #include <Array.au3> #include <_SCCM.au3> $sServer = "my-sccm" $sCode = "P01" $sPC = "JLVMWIN7x86" _SCCM_Connect($sServer, $sCode) $myResult = _SCCM_ListCollectionsForPC($sPC) If @error Then ConsoleWrite(@error & "|" & @extended & @CRLF) Else _ArrayDisplay($myResult) EndIf Return an array of all PCs in a given collection #include <Array.au3> #include <_SCCM.au3> $sServer = "my-sccm" $sCode = "P01" $sCollection = "Adobe Acrobat 8 Uninstall" _SCCM_Connect($sServer, $sCode) $myResult = _SCCM_ListPCsInCollection($sCollection) If @error Then ConsoleWrite(@error & "|" & @extended & @CRLF) Else _ArrayDisplay($myResult) EndIf Trigger the specified Update task on a client #include <Array.au3> #include <_SCCM.au3> $sServer = "my-sccm" $sCode = "P01" $sPC = "JLVMWIN7x86" _SCCM_Connect($sServer, $sCode) _SCCM_TriggerClientUpdate($sPC, $__SCCM_HARDWARE_INVENTORY) If @error Then ConsoleWrite(@error & "|" & @extended & @CRLF) Restart the SMS Agent Host Service on the specified PC #include <Array.au3> #include <_SCCM.au3> $sServer = "my-sccm" $sCode = "P01" $sPC = "JLVMWIN7x86" _SCCM_Connect($sServer, $sCode) _SCCM_RestartSvc($sPC) If @error Then ConsoleWrite(@error & "|" & @extended & @CRLF) Repair the Configuration Manager Client on the specified PC #include <Array.au3> #include <_SCCM.au3> $sServer = "my-sccm" $sCode = "P01" $sPC = "JLVMWIN7x86" _SCCM_Connect($sServer, $sCode) _SCCM_RepairClient($sPC) If @error Then ConsoleWrite(@error & "|" & @extended & @CRLF) Open the SCCM logs directory on the specified PC #include <Array.au3> #include <_SCCM.au3> $sServer = "my-sccm" $sCode = "P01" $sPC = "JLVMWIN7x86" _SCCM_Connect($sServer, $sCode) _SCCM_CheckLogs($sPC) If @error Then ConsoleWrite(@error & "|" & @extended & @CRLF) Delete an asset from the SCCM database #include <_SCCM.au3> $sServer = "afic-sccm" $sCode = "P01" $sPC = "JLVMWIN7x64" _SCCM_Connect($sServer, $sCode) $myReturn = _SCCM_DeletePC($sServer, $sCode, $sPC) If @error Then ConsoleWrite(@error & "|" & @extended & @CRLF) Search the SCCM database for conflicting records and merge #include <Array.au3> #include <_SCCM.au3> $sServer = "afic-sccm" $sCode = "P01" _SCCM_Connect($sServer, $sCode) _SCCM_MergeRecords() If @error Then ConsoleWrite(@error & "|" & @extended & @CRLF) Connect to the the SCCM database and refresh either a single collection or all collections. #include <_SCCM.au3> Local $sServer = "afic-sccm", $SCode = "P01" $myReturn = _SCCM_Connect($sServer, $SCode) _Example1() ;Refresh All Collections _Example2() ;Refresh Only the All Systems Device Collection Func _Example1() For $i = 1 To UBound($myReturn) - 1 _SCCM_RefreshCollection($sServer, $SCode, $myReturn[$i][1]) ConsoleWrite(((@error) ? "Error refreshing " & $myReturn[$i][0] : $myReturn[$i][0] & " refreshed successfully") & @CRLF) Next EndFunc Func _Example2() _SCCM_RefreshCollection($sServer, $SCode, 'SMS00001') ConsoleWrite(((@error) ? "Error refreshing All Systems Collection" : "All Systems Collection refreshed successfully") & @CRLF) EndFunc Edited April 12, 2015 by JLogan3o13 Wombat and argumentum 2 "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 More sharing options...
Moderators JLogan3o13 Posted October 14, 2014 Author Moderators Share Posted October 14, 2014 First post updated with one additional function and example "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 More sharing options...
Moderators JLogan3o13 Posted April 12, 2015 Author Moderators Share Posted April 12, 2015 First post updated with additional function and example: _SCCM_RefreshCollection "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 More sharing options...
ScriptingSteve Posted July 13, 2015 Share Posted July 13, 2015 Wonder if you have suggestion. Looking for an Autoit script to initiate the same process the SCCM 2012 R2 client would use to select an appropriate distribution point server name, based on current location, boundaries, etc., to pull a package.We are trying to implement MS Office 365 Click-to-run, and let the updates process run against the 'appropriate' SCCM DP for the update media... we want to select the same DP that SCCM would use for the PC in its current boundary.I hope that makes sense. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted July 13, 2015 Author Moderators Share Posted July 13, 2015 While not a part of the UDF, you could always use the current management point on each client, which will be up to date as of the last heartbeat check-in. Something like this will get you the name of the DP$oConfigMgr = ObjCreate("Microsoft.SMS.Client") If Not @error Then MsgBox(0, "", $oConfigMgr.GetCurrentManagementPoint) "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 More sharing options...
tcox8 Posted February 22, 2017 Share Posted February 22, 2017 Is this still being developed? I'm working on making a tool that allows my help desk to search for existing devices via Name, MAC address, or GUID and delete them from SCCM. "There are only 10 types of people in the world: Those who understand binary, and those who don't" Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted February 22, 2017 Author Moderators Share Posted February 22, 2017 @tcox8 unfortunately I have not been supporting any customers that use SCCM as of late, so have not updated this recently. In truth it needs a full re-write, in which I would probably simply wrap the PowerShell commands. "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 More sharing options...
tcox8 Posted February 22, 2017 Share Posted February 22, 2017 I'm familiar with all the powershell command but was in need of an .exe. I'll try to figure out how to wrap the powershell commands in autoit. Thanks! @JLogan3o13 "There are only 10 types of people in the world: Those who understand binary, and those who don't" Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted February 22, 2017 Author Moderators Share Posted February 22, 2017 There are a number of posts on the forum regarding wrapping an AutoIt GUI around powershell; a quick google or forum search should get you well along your way. "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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now