#include-once #include "Array.au3" #include "_SCCM_Constants.au3" ; #INDEX# ======================================================================================================================= ; Title .........: Systems Center Configuration Manager Library ; AutoIt Version : 3.3.12.0 ;Test on BETA before release ; UDF Version ...: 1.2.0.0 ; Language ......: English ; Description ...: A collection of functions for managing Microsoft SCCM 2012 and 2012 R2 ; Author(s) .....: JLogan3o13 ; Modified.......: 04.12.2015 ; Remarks .......: ; Resources .....: ; =============================================================================================================================== ; #CURRENT# ===================================================================================================================== ;_SCCM_Connect ;_SCCM_AddToCollection ;_SCCM_RemoveFromCollection ;_SCCM_RemoveAllPCsFromCollection ;_SCCM_ListCollectionsForPC ;_SCCM_ListPCsInCollection ;_SCCM_TriggerClientUpdate ;_SCCM_RestartSvc ;_SCCM_RepairClient ;_SCCM_CheckLogs ;_SCCM_DeletePC ;_SCCM_MergeRecords ;_SCCM_Search ;_SCCM_RefreshCollection ; ================================================================================================================================ #region #VARIABLES# ; #VARIABLES# =================================================================================================================== Global $__gaColls Global $__goSMS ; =============================================================================================================================== #EndRegion ; #FUNCTION# =========================_SCCM_Connect=================================================================================== ; Name...........: _SCCM_Connect ; Description ...: Connect to the SCCM Server for the Local Site ; Syntax.........: _SCCM_Connect($sServer, $sCode) ; Parameters ....: $sServer - The Local SCCM Site Server ; $sCode - The Local Site Code ; Return values .: Success - Creates a Locator object and Connects to the Local SCCM Site Server: ; Failure: @error set to 1 with a null string. @extended set to the following: ; 1 = Failed to create the Locator object ; 2 = Failed to connect to the SCCM Site Server ; Example........: Yes ; ==================================================================================================================================== Func _SCCM_Connect($sServer, $sCode) Local $oLocator = ObjCreate("WbemScripting.SWbemLocator") If IsObj($oLocator) Then $__goSMS = $oLocator.ConnectServer($sServer, "root\sms\site_" & $sCode) If @error Then Return SetError(1, 2, "") Else $__goSMS.Security_.ImpersonationLevel = 3 $__goSMS.Security_.AuthenticationLevel = 6 EndIf Else Return SetError(1, 1, "") EndIf $aResult = _SCCM_PullAllColls($sServer, $sCode) Return $aResult EndFunc ; #====================================SCCM FilterCollections========================================================================= ; Name...........: _SCCM_FilterColls ; Description ...: Pull a list of collections matching filter criteria from the SCCM Site Server ; Syntax.........: _SCCM_FilterColls($sCode, $sFilter) ; Parameters ....: $sCode - The Local Site Code ; $sFilter - A filter to search on. Typically this will be a string added to the Comment section (default = *) ; Return values .: Success - Returns a 2 dimensional filtered array with the following information: ; Column 0: Collection Name ; Column 1: Collection ID ; Failure: @error set to 1 with a null string. @extended set to the following: ; 1 = Query of Site Server failed to return Collection List ; ==================================================================================================================================== Func _SCCM_FilterColls($sCode, $sField, $sFilter) Local $oResults = $__goSMS.ExecQuery("SELECT * FROM SMS_Collection WHERE " & $sField & " LIKE '%" & $sFilter & "%' ORDER by Name") If $oResults.Count = 0 Then Return SetError(1, 1, "") Else Dim $afColls[$oResults.Count][2] $iIndex = 0 For $element In $oResults $afColls[$iIndex][0] = $element.Name $afColls[$iIndex][1] = $element.CollectionID $iIndex += 1 Next Return $afColls EndIf EndFunc ; #FUNCTION# =========================_SCCM_AddToCollection=========================================================================== ; Name...........: _SCCM_AddToCollection ; Description ...: Add an asset to the specified collection ; Syntax.........: _SCCM_AddToCollection($sPC, $sCollection) ; Parameters ....: $sPC - The asset to add ; $sCollection - The collection to add the asset to ; Return values .: Success - Adds the selected asset to the specified collection: ; Failure: @error set to 1 with a null string. @extended set to the following: ; 1 = Failed to find Collection ID based on Collection Name specified ; 2 = Failed to find Computer in Database ; 3 = Failed to find Resource ID based on Computer Name specified ; Example........: Yes ; ==================================================================================================================================== Func _SCCM_AddToCollection($sPC, $sCollection) Local $oResults, $sResourceID For $i = 0 To UBound($__gaColls) - 1 If $__gaColls[$i][0] = $sCollection Then $sColID = $__gaColls[$i][1] EndIf Next If $sColID = "" Then Return SetError(1, 1, "") Else $oResults = $__goSMS.ExecQuery("SELECT * FROM SMS_R_System WHERE Name = '" & $sPC & "'") If $oResults.Count = 0 Then Return SetError(1, 2, "") Else For $element In $oResults $sResourceID = $element.ResourceID Next If $sResourceID = "" Then Return SetError(1, 3, "") Else $oCollection = $__goSMS.Get("SMS_Collection.CollectionID=" & """" & $sColID & """") $oRule = $__goSMS.Get("SMS_CollectionRuleDirect").SpawnInstance_() $oRule.ResourceClassName = "SMS_R_System" $oRule.ResourceID = $sResourceID $oCollection.AddMembershipRule($oRule) EndIf EndIf EndIf EndFunc ; #FUNCTION# =========================_SCCM_RemoveFromCollection====================================================================== ; Name...........: _SCCM_RemoveFromCollection ; Description ...: Remove an asset from the specified collection ; Syntax.........: _SCCM_RemoveFromCollection($sPC, $sCollection) ; Parameters ....: $sPC - The asset to remove ; $sCollection - The collection to remove the asset from ; Return values .: Success - Removes the selected asset from the specified collection: ; Failure: @error set to 1 with a null string. @extended set to the following: ; 1 = Failed to find Collection ID based on Collection Name specified ; 2 = Failed to find Computer in Database ; 3 = Failed to find Resource ID based on Computer Name specified ; 4 = Specified asset is not a member of the collection ; Example........: Yes ; ==================================================================================================================================== Func _SCCM_RemoveFromCollection($sPC, $sCollection) Local $sColID, $oResults For $i = 0 To UBound($__gaColls) - 1 If $__gaColls[$i][0] = $sCollection Then $sColID = $__gaColls[$i][1] Next If $sColID = "" Then Return SetError(1, 1, "") Else $oResults = $__goSMS.ExecQuery("SELECT * FROM SMS_R_System WHERE Name = '" & $sPC & "'") If $oResults.Count = 0 Then Return SetError(1, 2, "") Else For $element In $oResults Local $sResourceID = $element.ResourceID Next If $sResourceID = "" Then Return SetError(1, 3, "") Else $oCollection = $__goSMS.Get("SMS_Collection.CollectionID=" & """" & $sColID & """") $oRule = $__goSMS.Get("SMS_CollectionRuleDirect").SpawnInstance_() $oRule.ResourceClassName = "SMS_R_System" $oRule.ResourceID = $sResourceID $oCollection.DeleteMembershipRule($oRule) If @error = -2147352567 Then Return SetError(1, 4, "") ;2147352567 Exception occurred, asset not a collection member EndIf EndIf EndIf EndFunc ; #FUNCTION# ==========================SCCm RemoveAllPCsFromCollection================================================================ ; Name...........: _SCCM_RemoveAllPCsFromCollection ; Description ...: Removes all assets from a given Collection ; Syntax.........: _SCCM_RemoveAllPCsFromCollection($sCollection) ; Parameters ....: $sCollection - The Collection to remove all assets from. ; Return values .: Success - Removes all assets in given collection: ; Failure: @error set to 1 with a null string. @extended set to the following: ; 1 = Failed to find Collection ID, Name ; 2 = Query for Collection returned no results ; 3 = No Assets found in Collection ; Example........: Yes ; ==================================================================================================================================== Func _SCCM_RemoveAllPCsFromCollection($sCollection) Local $sColID, $oResults For $i = 0 To UBound($__gaColls) -1 If $__gaColls[$i][0] = $sCollection Then $sColID = $__gaColls[$i][1] Next If $sColID = "" Then Return SetError(1, 1, "") Else $oResults = $__goSMS.ExecQuery("Select * From SMS_Collection where CollectionID = '" & $sColID & "'") If $oResults.Count = 0 Then Return SetError(1, 2, "") Else For $element In $oResults $oCollection = $__goSMS.Get("SMS_Collection='" & $element.CollectionID & "'") $oRules = $oCollection.CollectionRules If $oRules <> Null Then For $rule In $oRules $oCollection.DeleteMembershipRule($rule) Next Else Return SetError(1, 3, "") EndIf Next EndIf EndIf EndFunc ; #FUNCTION# =========================_SCCM_ListCollectionsForPC====================================================================== ; Name...........: _SCCM_ListCollectionsForPC ; Description ...: List all collections for which specified asset is a member ; Syntax.........: _SCCM_ListCollectionsForPC($sPC) ; Parameters ....: $sPC - The asset to query for collection membership ; Return values .: Success - Returns a 1 dimensional array with all collections the specified asset is a member of ; Failure: The only way to generate an error is if the asset is not found in the SCCM db. Otherwise, it will be ; a member of at least one Collection (All systems) ; @error set to 1 with a null string. @extended set to the following: ; 1 = Specified Computer not in Database ; 2 = Failed to find Resource ID based on Computer Name specified ; 3 = Query returned 0 results; the specified asset is not a member of any collections (should not be possible) ; Example........: Yes ; ==================================================================================================================================== Func _SCCM_ListCollectionsForPC($sPC) Local $oResults, $sResourceID, $aCollection, $oCollections Local $aCollectionsForPC[0] $oResults = $__goSMS.ExecQuery("SELECT * FROM SMS_R_System WHERE Name = '" & $sPC & "'") If $oResults.Count = 0 Then Return SetError(1, 1, "") Else For $element In $oResults $sResourceID = $element.ResourceID Next If $sResourceID = "" Then Return SetError(1, 2, "") Else $oCollections = $__goSMS.ExecQuery("SELECT * from SMS_FullCollectionMembership where ResourceID='" & $sResourceID &"'") If $oResults.Count = 0 Then Return SetError(1, 3, "") Else _ArrayAdd($aCollectionsForPC, $oResults.Count) For $element in $oCollections For $i = 0 To UBound($__gaColls) - 1 If $element.CollectionID = $__gaColls[$i][1] Then _ArrayAdd($aCollectionsForPC, $__gaColls[$i][0]) Next Next _ArraySort($aCollectionsForPC, Default, 1) Return($aCollectionsForPC) EndIf EndIf EndIf EndFunc ; #FUNCTION# =========================_SCCM_ListPCsInCollection======================================================================= ; Name...........: _SCCM_ListPCsInCollection ; Description ...: List all assets in a specified collection ; Syntax.........: _SCCM_ListPCsInCollection($sCollection) ; Parameters ....: $sCollection - The collection to query for asset membership ; Return values .: Success - Returns a 1 dimensional array with all assets within the specified collection ; Failure: @error set to 1 with a null string. @extended set to the following: ; 1 = Failed to find Collection ID based on Collection Name specified ; 2 = Query returned 0 results; there are no assets in the specified collection ; Example........: Yes ; ==================================================================================================================================== Func _SCCM_ListPCsInCollection($sCollection) Local $oResults, $sColID Local $aPCsInCollection[0] For $i = 0 To UBound($__gaColls) -1 If $sCollection = $__gaColls[$i][0] Then $sColID = $__gaColls[$i][1] Next If $sColID = "" Then Return SetError(1, 1, "") Else $oResults = $__goSMS.ExecQuery("SELECT * FROM SMS_FullCollectionMembership WHERE CollectionID = '" & $sColID & "'") If $oResults.Count > 0 Then _ArrayAdd($aPCsInCollection, $oResults.Count) For $element In $oResults _ArrayAdd($aPCsInCollection, $element.Name) Next _ArraySort($aPCsInCollection, Default, 1) Return $aPCsInCollection Else Return SetError(1, 2, "") EndIf EndIf EndFunc ; #FUNCTION# ==========================SCCM TriggerClientUpdate======================================================================= ; Name...........: _SCCM_TriggerClientUpdate ; Description ...: Triggers the specified update task on the resource. Must be able to ping the machine. ; Syntax.........: _SCCM_TriggerClientUpdate($sPC, $sTrigger) ; Parameters ....: $sPC - The asset to remove ; Optional: $sTrigger - The Client Action to Trigger (default = $__SCCM_REQUEST_MACHINE_ASSIGNMENTS) ; Return values .: Success - Triggers the requested action on the resource: ; Failure: @error set to 1 with a null string. @extended set to the following: ; 1 = Machine is unreachable ; 2 = Failed to connect to the WMI namespace on the machine ; 3 = Failed to trigger the selected action, check machine logs for detailed information ; Example........: Yes ; ==================================================================================================================================== Func _SCCM_TriggerClientUpdate($sPC, $sTrigger = $__SCCM_REQUEST_MACHINE_ASSIGNMENTS) If Not Ping($sPC) Then Return SetError(1, 1, "") Else $oCCMNamespace = ObjGet("winmgmts://" & $sPC & "/root/ccm") If Not IsObj($oCCMNamespace) Then Return SetError(1, 2, "") Else $oInstance = $oCCMNamespace.Get("SMS_Client") $oParams = $oInstance.Methods_("TriggerSchedule").inParameters.SpawnInstance_() $oParams.sScheduleID = $sTrigger $oCCMNamespace.ExecMethod("SMS_Client", "TriggerSchedule", $oParams) If @error Then Return SetError(1, 3, "") EndIf EndIf EndFunc ; #FUNCTION# ==========================SCCM RestartSvc================================================================================ ; Name...........: _SCCM_RestartSvc ; Description ...: Stops and restarts the SMS Agent Host service (ccmexec) on the specified asset ; Syntax.........: RestartSvc($sPC) ; Parameters ....: $sPC - The asset to connect to ; Return values .: Success - Stops and then restarts the SMS Agent Host service on the specified asset ; Failure: @error set to 1 with a null string. @extended set to the following: ; 1 = Machine is unreachable ; 2 = Failed to connect to the WMI namespace on the machine ; 3 = WMI query failed to return a list of services ; 4 = CCMExec service not found/installed on the machine ; Example........: Yes ; ==================================================================================================================================== Func _SCCM_RestartSvc($sPC) Local $wbemFlagReturnImmediately = 0x10 Local $wbemFlagForwardOnly = 0x20 Local $bBool = False If Not Ping($sPC) Then Return SetError(1, 1, "") Else $oWMI = ObjGet("winmgmts://" & $sPC & "\root\CIMV2") If Not IsObj($oWMI) Then Return SetError(1, 2, "") Else $oItems = $oWMI.ExecQuery("SELECT * FROM Win32_Service Where Name LIKE 'CCMExec'", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If Not IsObj($oItems) Then Return SetError(1, 3, "") Else For $service In $oItems If $service.Name = "CCmExec" Then $service.StopService Sleep(5000) $service.StartService $bBool = True EndIf Next If $bBool <> True Then Return SetError(1, 4, "") EndIf Endif EndIf EndFunc ; #FUNCTION# ==========================SCCM RepairClient============================================================================== ; Name...........: _SCCM_RepairClient ; Description ...: Repairs the Config Manager client on the specified asset ; Syntax.........: _SCCM_RepairClient($sPC) ; Parameters ....: $sPC - The asset to connect to ; Return values .: Success - Launches ccmrepair.exe on the asset to repair the Config Mgr. client. ; Note - This may take up to 10 minutes to complete! ; Failure: @error set to 1 with a null string. @extended set to the following: ; 1 = Machine is unreachable ; 2 = Failed to query the machine for OS Architecture ; 3 = CCMRepair.exe does not exist on the asset ; 4 = Failed to connect to the WMI namespace and obtain the SMSClient object ; Example........: Yes ; ==================================================================================================================================== Func _SCCM_RepairClient($sPC) If Not Ping($sPC) Then Return SetError(1, 1, "") Else $myReturn = _SCCM_RemoteArch($sPC) If @error = 1 Then Return SetError(1, 2, "") Else $sRepair = (($myReturn = "x86") ? "\\" & $sPC & "\C$\Windows\CCM\ccmrepair.exe" : "\\" & $sPC & "\C$\Windows\CCM\ccmrepair.exe") EndIf If Not FileExists($sRepair) Then Return SetError(1, 3, "") Else $SmsClient = ObjGet("winmgmts://" & $sPC & "/Root/Ccm:SMS_Client") If IsObj($SmsClient) Then $SmsClient.RepairClient Else Return SetError(1, 4, "") EndIf EndIf EndIf EndFunc ; #FUNCTION# ==========================SCCM CheckLogs================================================================================== ; Name...........: _SCCM_CheckLogs ; Description ...: Opens the SCCM logs directory on the specified asset ; Syntax.........: _SCCM_CheckLogs($sPC) ; Parameters ....: $sPC - The asset to connect to ; Return values .: Success - Opens a FileDialog box to the SCCM logs directory on the specified asset ; Failure: @error set to 1 with a null string. @extended set to the following: ; 1 = Machine is unreachable ; 2 = Failed to query the machine for OS Architecture ; 3 = The SCCM logs directory does not exist on the machine ; Example........: Yes ; ==================================================================================================================================== Func _SCCM_CheckLogs($sPC) If Not Ping($sPC) Then Return SetError(1, 1, "") Else $myReturn = _SCCM_RemoteArch($sPC) If @error = 1 Then Return SetError(1, 2, "") Else $logsDir = (($myReturn = "x86") ? "\\" & $sPC & "\C$\Windows\CCM\Logs" : "\\" & $sPC & "\C$\Windows\CCM\Logs") If Not FileExists($logsDir) Then Return SetError(1, 3, "") Else FileOpenDialog("SCCM Logs on " & $sPC, $logsDir, "Logs (*.log)") EndIf EndIf EndIf EndFunc ; #FUNCTION# ==========================SCCM Delete PC=============================================================================== ; Name...........: _SCCM_DeletePC ; Description ...: Deletes a machine record from the SCCM database ; Syntax.........: _SCCM_DeletePC($sServer, $sCode, $sPC) ; Parameters ....: $sServer - The Local SCCM Site Server ; $sCode - The Local Site Code ; Parameters ....: $sPC - The asset to delete ; Return values .: Success - The record is deleted from the database. ; Failure: @error set to 1 with a null string. @extended set to the following: ; 1 = Query for objects in the All Systems collection failed, or no records returned ; 2 = Failed to delete asset from the SCCM database ; 3 = Specified asset not found in the SCCM database ; Example........: Yes ; ==================================================================================================================================== Func _SCCM_DeletePC($sServer, $sCode, $sPC) Local $bBool = False Local $oResults = $__goSMS.ExecQuery("SELECT * FROM SMS_FullCollectionMembership WHERE CollectionID = 'SMS00001'") If $oResults.Count = 0 Then Return SetError(1, 1, "") Else For $machine In $oResults If $machine.Name = $sPC Then $bBool = True $RID = $machine.ResourceID $oRecord = ObjGet( "WinMgmts:\\" & $sServer & "\root\SMS\site_" & $sCode & ":SMS_R_System.ResourceID=" & $RID) $oRecord.Delete_ If @error Then Return SetError(1, 2, "") EndIf Next If Not $bBool Then Return SetError(1, 3, "") EndIf EndFunc ; #FUNCTION# ==========================SCCM MergeRecords=============================================================================== ; Name...........: _SCCM_MergeRecords ; Description ...: Searches the SCCM database for conflicting records and merges them ; Syntax.........: _SCCM_MergeRecords() ; Parameters ....: N/A ; Return values .: Success - Queries for all conflicting records and merges them. May take up to 2 minutes to complete. ; Failure: @error set to 1 with a null string. @extended set to the following: ; 1 = Failed to obtain the Provider Location object ; 2 = Query to return Pending Registration Records failed, no records in database ; 3 = Resolve Pending Record Execution failed ; Example........: Yes ; ==================================================================================================================================== Func _SCCM_MergeRecords() $oProviderLocation = $__goSMS.InstancesOf("SMS_ProviderLocation") If Not IsObj($oProviderLocation) Then Return SetError(1, 1, "") Else $oPendingRegs = $__goSMS.ExecQuery("SELECT * FROM SMS_PendingRegistrationRecord") If $oPendingRegs.Count = 0 Then Return SetError(1, 2, "") Else For $pending In $oPendingRegs $oInParams = $__goSMS.Get("SMS_PendingRegistrationRecord").Methods_("ResolvePendingRegistrationRecord").InParameters.SpawnInstance_ $oInParams.Action = "1" $oInParams.SMSID = $pending.SMSID $__goSMS.ExecMethod("SMS_PendingRegistrationRecord","ResolvePendingRegistrationRecord", $oInParams) If @error Then Return SetError(1, 3, "") ExitLoop EndIf Next EndIf EndIf EndFunc ; #FUNCTION# ==========================SCCM Search===================================================================================== ; Name...........: _SCCM_Search ; Description ...: Searches the SCCM database for assets matching the specified string ; Syntax.........: _SCCM_Search($sString) ; Parameters ....: $sString - A full or partial asset name to search the database for. ; Return values .: Success - Returns a 1 dimensional array of assets that match the specified string. ; Failure: @error set to 1 with a null string. @extended set to the following: ; 1 = No Array returned; no assets match the search string ; Example........: Yes ; ==================================================================================================================================== Func _SCCM_Search($sString) Local $aSearch[1] = [""], $iCount = 0 Local $oResults = $__goSMS.ExecQuery("SELECT * from SMS_R_System where Name LIKE '%" & $sString & "%'") $iCount = $oResults.Count $aSearch[0] = $iCount For $element In $oResults _ArrayAdd($aSearch, $element.Name) Next _ArraySort($aSearch, Default, 1) Return($aSearch) EndFunc ; #FUNCTION# ==========================SCCM Refresh Collection======================================================================== ; Name...........: _SCCM_RefreshCollection ; Description ...: Refreshes a given Collection in the SCCM Database ; Syntax.........: _SCCM_RefreshCollection($sServer, $sCode, $sCollection) ; Parameters ....: $sServer - The Local SCCM Site Server ; $sCode - The Local Site Code ; $sCollection - The CollectionID of the Collection to refresh ; Return values .: Success - Refreshes the specified collections and sets Error to 0 ; Failure: @error set to 1 with a null string. @extended set to the following: ; 1 = $oCollection is not an object (Collection ID not found in database) ; 2 = Failed to refresh specified collection ; Example........: Yes ; ==================================================================================================================================== Func _SCCM_RefreshCollection($sServer, $sCode, $sCollection) Local $oCollection = ObjGet("WinMgmts:!\\" & $sServer & "\root\SMS\site_" & $sCode & ":SMS_Collection.CollectionID='" & $sCollection & "'") If IsObj($oCollection) Then $oCollection.RequestRefresh("False") If @error Then Return(SetError(1, 2, "")) Else Return(SetError(1, 1, "")) ;$oCollection not an object EndIf EndFunc #Region #INTERNAL USE ONLY# ; #=================================================================================================================================== ; Name...........: _SCCM_PullAllColls ; Description ...: Pull a list of all collections from the SCCM Site Server ; Syntax.........: _SCCM_PullColls($sServer, $sCode) ; Parameters ....: $sServer - The Local SCCM Site Server ; $sCode - The Local Site Code ; Return values .: Success - Returns a 2 dimensional array with the following information: ; Column 0: Collection Name ; Column 1: Collection ID ; Failure: @error set to 1 with a null string. @extended set to the following: ; 1 = Query of Site Server failed to return Collection List ; ==================================================================================================================================== Func _SCCM_PullAllColls($sServer, $sCode) ;Pull a list of SCCM collections into an Array Local $oResults = $__goSMS.ExecQuery("SELECT * FROM SMS_Collection ORDER by Name") If $oResults.Count = 0 Then Return SetError(1, 1, "") Else Dim $__gaColls[$oResults.Count][2] $iIndex = 0 For $element In $oResults $__gaColls[$iIndex][0] = $element.Name $__gaColls[$iIndex][1] = $element.CollectionID $iIndex += 1 Next Return $__gaColls EndIf EndFunc ; #=================================================================================================================================== ; Name...........: _SCCM_RemoteArch ; Description ...: Internal function to determine OSArchitecture of specified asset ; Syntax.........: _SCCM_RemoteArch($sPC) ; Parameters ....: $sPC - The asset to connect to ; Return values .: Success - Returns a string representing the OSArchitecture of the asset ; Failure: @error set to 1 with a null string. @extended set to the following: ; 1 = Failed to connect to the WMI namespace on the asset ; 2 = Query failed to return the specified WMI collection ; ==================================================================================================================================== Func _SCCM_RemoteArch($sPC) Local $sArch = "" $oWMI = ObjGet("winmgmts:\\" & $sPC & "\root\cimv2") If Not IsObj($oWMI) Then Return SetError(1, 1, "") Else $aItems = $oWMI.ExecQuery("Select * from Win32_Processor WHERE AddressWidth='64'") $sArch = (($aItems.Count = 0) ? "x86" : "x64") Return($sArch) EndIf EndFunc #EndRegion