On this page:

Creating an Instruction that executes a Script

Now that we have created two complex Instructions using the native language, we will create an Instruction using a PowerShell (PS) script. There may be instances where you might not be able to accomplish your end goal using just the native language. Or you might already have a script that uses complex logic to return information you are looking for or execute an action you want on your endpoints. In these cases, you can create an Instruction which employs a PS script.

Create an Instruction

In this task, we will create a query that identifies what the ConfigMgr assigned Site code is for our clients.

Create a Query

  1. In TIMS, go to File and select New to clear the existing instruction definition
  2. In the query window, copy in the following query
  3. NativeServices.RunWmiQuery(Namespace:"root\\ccm", Query:"SELECT name from sms_authority");
    Root\CCM is the ConfigMgr client WMI namespace, and SMS_Authority is the space under which the installed site value is saved, as the value name.
  4. Click the Run button
  5. Note the value that returns. This is the site code for the CM site in our lab environment
  6. In the Instruction Definition pane on the top right, input the following for Description and ReadablePayload
  7. What is the SCCM Site code?
  8. Name the Instruction 1ETRN-Check SCCM Site
  9. Click the Schema button in the top ribbon and validate the suggested schema. Click OK
  10. From the menu, click File->Save as. Click OK on the Validation page
  11. Save the instruction as CheckSCCMSite.XML under C:\Tools

Creating an Action Instruction that Contains a Script

In this task, we will create an action Instruction that changes the CM site code on the Tachyon clients. We will accomplish this using a PowerShell script.

  1. Navigate to \\1ETRNAP\Temp and copy setSCCMSite.ps1 to c:\tools  when that finishes right click the setSCCMsite.ps1 file
  2. Edit with Notepad and review the syntax of the file
  3. The file is using a ConfigMgr client module to set the assigned site of a ConfigMgr client to whatever parameter is being passed to the script.
  4. In the TIMS console menu, click on File and select New. Click OK
  5. From the ribbon along the top, select Import resource
  6. Browse to C:\Tools and select the setSCCMsite.ps1 file
  7. In the Instruction Resource popup, review the settings and click OK
  8. Click Add parameter from the top ribbon and input SCCMSite into the name
  9. In the Max Length box, input 3. Click OK
  10. In the Middle pane, click the down arrow for the Resources next to the file name setSCCMsite and select Insert snippet to download
  11. This step will add syntax to the instruction for where to download the file, including the hash of the file. The script will actually be embedded in the instruction XML, so download instructions must reside within the instruction.
  12. On the line beneath the file download syntax, paste in the following
  13. Scripting.Run(Language:"PowerShell",ExecutionPolicy:"Override",Script:@resource1,InterpretAsJson:False,"%SCCMSite%");
    This syntax is referencing the script which we have imported into this Instruction, along with the parameter SCCMSite which we have defined. That parameter is what gets passed to the script from what's inputted by the administrator in the Tachyon Explorer application.
  14. In the Instruction Definition pane on the top right, input something into Description
  15. Name the Instruction 1ETRN-Set SCCM Site Code
  16. Change the InstructionType to Action using the dropdown menu
  17. In the ReadablePayload field, input the following: Change the SCCM Site code to %SCCMSite%
  18. From the ribbon click on Schema
  19. In the Edit Schema page, click the green+button. In the Column Name input ExitCode and change Data Type to int32
  20. Click the green+button again and in the Column Name input Output and leave the Data Type as String. Click OK
  21. Click the Workflow button in the top ribbon. From the dropdown, select No user approval. Click OK
  22. Click the Run button from the top ribbon. Input a 3 character value into the Parameters field
  23. Validate the results
  24. There are two columns outputted from the Instruction, an ExitCode and an Output column. The schema definition will define the actual output the Explorer Application will display.
  25. From the menu, click File-> Save as. Click OK on the Validation page
  26. Save the instruction as SETSCCMSite.XML under C:\Tools

Upload Instructions to Tachyon

Now that we have two instructions, a question and an action, we are ready to upload them to Tachyon as a Product Pack.

  1. Browse to C:\Tools and multiselect the CheckSCCMSIte.XML and SETSCCMSIte.XML files
  2. Right click on the selected files and select Send to> Compressed (zipped) folder
  3. Name the zip file SCCMSite.zip and Copy from C:\Tools to the Config Mgr Source folder using the desktop shortcut
  1. Copy the SCCMSite.zip from Config Mgr Source to C:\Temp.
  2. In the browser, if the Tachyon Settings application is not already running, navigate to HTTPS:\\Tachyon.1ETRN.local\Tachyon and navigate to Instructions - Instruction Sets
  3. Click the Upload button at the top right and browse out to C:\Temp. Select the SCCMSite.zip file and click Open
  4. Validate that the file was uploaded with no errors 
  5. Select the two instructions uploaded via the Product Pack named What is the SCCM Site code? and Change the SCCM Site code to <SCCMSite>
  6. Click Move and move the Instructions into the 1ETRN Instruction Set

Running Instructions

Now that we've created Instructions and added them to Tachyon, we are ready to validate that the instructions execute exactly what we defined within them, and output the appropriate information when run.

  1. Navigate to the home page of Tachyon Explorer
  2. In the I want to know box, type in What is the SCCM Site code
  3. Click Ask this question
  4. Wait for all clients to respond. Note the Results return in the form of Device Name and Name for the SCCM Site code, and the value is in the form of SMS:xxx (Remember 1 will be the value you changed it to in Step 362)
  5. The Site code for the SCCM site in our lab environment is PS1. Keep note of this as we change the site code.
  6. Once all results are in, click on the Actions tab
  7. Type in Change the SCCM Site code
  8. Input AAA into the site code parameter box and click Perform this action
  9. Note the results. There will be 3 columns, Device Name, Exit Code and New SCCM Site
  10. The Exit Code and New SCCM Site are columns we defined in the schema when creating the Instruction, the Device Name is always returned as part of the results.
  11. From the Start menu, click on Control Panel. Under the Control Panel, click on the Configuration Manager applet
  12. Navigate to the Site tab and validate the Site code
  13. The site code should now be set to the 3 character value you inputted into the Instruction.

Lab Summary

In this lab, we created an Instruction using a PowerShell script. Everything about the Instruction is the same, in terms of defining the schema and all the other values of the Instruction. The difference is that instead of using the SCALE language to develop the Instruction, we are employing a PS script to do the work for us.

Next Page
Ex 6 - TCN Adv 5.0 - Visualization and Aggregation