This topic references the following Activities:
LogClientNotInstalled : Logger
GetCCMEXECService : ServiceControl
ServiceStatePlaceholder : Empty
SwitchStartState : Switch-Case
GetSMSClientInfo
Activity: SmsClient, Operation: Get Client Info
The workflow starts by first querying the installed SMS/SCCM Client. This activity uses the Microsoft ISmsClient Client COM Automation Interface to obtain client information.
The information returned is whether or not the SMS or SCCM Client is installed, the SCCM Client Version, the Management Point, the Assigned Site and the SMSID (Unique Identifier).
For this activity, we do not need to specify anything other than the operation to Get Client Info.
IfClientInstalled
Activity: If-Else
The workflow then checks to see whether the SMS/SCCM client have been installed. To do this we use an If-Else statement to evaluate a logical condition. In this case, as the previous activity has two properties (IsSmsClientInstalled and IsSCCMClientInstalled) to tell us whether or not the SMS or SCCM client respectively is installed we evaluate both and if either is true then we know a client is installed.The expression of the If-Else statement is:
GetSMSClientInfo.IsSmsClientInstalled || GetSMSClientInfo.IsSccmClientInstalled
The || operator is the OR operator. If either of the two statements are true (i.e. the SMS Client is installed OR the SCCM client is installed) then the condition is evaluated to TRUE. If both are not true then the condition evaluates to FALSE.
Note: The single-pipe character | could also have been used for the OR. A single pipe evaluates both sides of the OR before returning, the double-pipe evaluates the left side and only if that is not true, evaluates the right side.
Depending on the evaluation of the If-Else condition depends on whether the workflow proceeds down the ClientInstalled (TRUE) or ClientNotInstalled (FALSE) path.
LogClientNotInstalled
Activity: Logger
If the If-Else condition evaluates to FALSE (No SMS/ConfigMgr client installed) then we want to output the fact that there was no client installed into the log.
The Logger activity will write an entry into the workflow log for the executing workflow. Note: This assumes that logging was enabled when the workflow was deployed.
The activity only requires one property to be specified which is the text to output into the active log. This can be specified as an Initial Value or as a Runtime Expression.
In this example, the output The SMS/ConfigMgr Client is not installed is output as an Initial Value.
GetCCMEXECService
Activity: ServiceControl, Operation: GetServiceInformation
The workflow then checks the ccmexec service information using the GetServiceInformation operation of the ServiceControl activity. This activity returns the ServiceName, DisplayName, ServiceDescription, Executable Path, Startyp Type, Current State, Dependencies, LogOn, Own Process and Interactive properties for the ccmexec service.
The purpose of this activity is to retrieve the current state of the service (running, stopped, start pending etc.).
This activity and operation combination takes one input property - ServiceName. This should be the exact name of the service itself, and not the service displayname.
IfServiceFound
Activity: If-Else
The workflow then checks to see whether the ccmexec service actually exists and if we've been able to query it. To do this we use an If-Else statement to evaluate a logical condition. In this case, we evaluate the Result of the previous GetCCMEXECService activity. The Result property indicates whether we were able to successfully query the Service information.
The expression of the If-Else statement is:
GetCCMEXECService.Result
Note: Because the Result property is a BOOLEAN datatype we can just use the property itself. It would also be valid to use GetCCMEXECService.Result = true.
Depending on the evaluation of the If-Else condition depends on whether the workflow proceeds down the ServiceFound (TRUE) or ServiceNotFound (FALSE) path.
LogServiceNotFound
Activity: Logger
If the If-Else condition evaluates to FALSE (Service does not exist or unable to query service information) then we want to output the fact that the service information cannot be found to the log.
The Logger activity will write an entry into the workflow log for the executing workflow. Note: This assumes that logging was enabled when the workflow was deployed.
The activity only requires one property to be specified which is the text to output into the active log. This can be specified as an Initial Value or as a Runtime Expression.
In this example, the output The CCMEXEC service cannot be found is output as an Initial Value.
ServiceStatePlaceholder
Activity: Empty
The ServiceStatePlaceholder node uses an Empty activity. The empty activity has no operations or input/output properties other than the generic name, description and logData. It can be used for outputting to the log using the LogData node or in the case of this, as a container for custom User Defined Properties.
In this activity, a single User Defined Property has been created called ServiceStateText with a datatype of TEXT and this will be used by the step below to store the evaluated service state as a text string. It has no initial value or runtime expression and gets a value stored during execution of the SwitchStartState activity below.
SwitchStartState
Activity: Switch-Case
The SwitchStartState node uses a Switch-Case activity. The Switch-Case activity can be used to evaluate an expression of either a TEXT (string), WHOLE NUMBER (int), FRACTIONAL NUMBER (double/decimal) or DATETIME datatype, and then depending on the result of the expression, go down one of multiple different paths.
In this example, we are evaluating the result of the CurrentState property of the GetCCMEXECService node above. This CurrentState property returns a numeric value (integer) for the state, with possible values being 1: Stopped, 2: Start Pendin, 3: Stop Pending, 4: Running, 5: Continue Pending, 6: Pause Pending, 7: Paused. The purpose of this activity is to query the numeric value and then set a text representation of the actual state into the ServiceStateText in the Empty property ServiceStatePlaceholder above.
As an example, if the service was in the 'Running' state, the SwitchStartState activity would evaluate the condition of GetCCMEXECService.CurrentState, would determine that the value was 4 and so would enter the child node that has a value of 4 (The node named Running).
After entering the child node for the respective value, the next thing the workflow does is uses the External Node property setter, to set the value of ServiceStateText in the ServiceStatePlaceholder activity above. The value of ServiceStatePlaceholder.ServiceStateText can then be used in the LogSMSClientInfo activity.
LogSMSClientInfo
Activity: Logger
The final activity is responsible for logging the SMS/SCCM client information.
The Logger activity will write an entry into the workflow log for the executing workflow. Note: This assumes that logging was enabled when the workflow was deployed.
The activity only requires one property to be specified which is the text to output into the active log. This can be specified as an Initial Value or as a Runtime Expression.
In this example, the output is specified as a Runtime Expression and amalgamates all of the client information obtained by the previous activities. Because a Runtime Expression is being specified, the text much be enclosed in double-quotes ("..."). The + symbol is used to concatenate (join) different strings and properties together.
This example outputs the following:
"The SMS/ConfigMgr Client has been found.
The assigned site is: " + GetSMSClientInfo.AssignedSite + ".
The client version is: " + GetSMSClientInfo.ClientVersion + ".
The assigned management point is: " + GetSMSClientInfo.ManagementPoint + ".
The SMS Unique ID is: " + GetSMSClientInfo.SMSID + ".
The current service state is: " + ServiceStatePlaceholder.ServiceStateText
After logging the Service and General Information about the SMS/ConfigMgr client, the workflow ends.
Full Workflow:
The workflow used in this example can be downloaded from the link below.
Comments
0 comments
Please sign in to leave a comment.