Skip to content

Using in a SCCM Package

Daniel Thompson edited this page Apr 12, 2024 · 9 revisions

Adding the Module

This is one way for adding this module into an SCCM package. You may modify it according to your needs, or do something else. You do you.

  1. Create a directory inside your package to hold this and other Git projects you may want to use. Lets call this Git. If you already have such a directory, you obviously can skip this step and use that directory.
  2. Install Git on the computer you will be using to edit your package, and add the git executable to your path. Details on how to do this are beyond the scope of this article.
  3. Use Git to download this repository:
    1. Open a command shell (such as Terminal, Command Prompt, or PowerShell).
    2. Change into the Git directory.
    3. Pull down the latest version of the module with the following command: git clone https://github.com/cwru-non-academic/posh-sccmtstools.git
  4. Your directory structure should look like:
    • Git
      • posh-sccmtstools
        • SCCMTSTools
          • 1.0.0
            • Functions
  5. Remember to redistribute your package to your distribution points at some point after adding this module.

Updating the Module

If you followed the instructions above for adding the module to your package, to update the module:

  1. Delete the existing posh-sccmtstools directory (Git doesn't seem to like cloning over an old copy of the repository).
  2. Open a command shell (such as Terminal, Command Prompt, or PowerShell).
  3. Change into the Git directory.
  4. Update the module with the following command: git clone https://github.com/cwru-non-academic/posh-sccmtstools.git
  5. Remember to redistribute your package to your distribution points at some point after updating this module.

Using the Module

All Functions

  1. Determine if the function(s) you are using is/are interactive in that function's help or in the Function Reference page in this wiki. Don't mix calls to interactive and non-interactive functions in the same script file.
  2. Import the module before you call any of its functions. If you set things up as recommended above, you can use this line of code: Import-Module -Name "$PSScriptRoot\Git\posh-sccmtools\SCCMTSTools"
  3. Call functions as needed from a PowerShell script file. We will assume this lives in the root of your SCCM package. Then follow the instructions in the appropriate section below.

Interactive Functions

  1. You will need the ServiceUI executable or some other executable that can run powershell.exe interactively in your package or in the path in your boot media. Doing this is outside the scope of this documentation. A quick web search should come up with instructions. Here, we will assume ServiceUI has been put into the root of your package as ServiceUI.exe.
  2. Add a Run Command Line step to your task sequence, giving it an appropriate name and description.
  3. Determine the path to powershell.exe in your boot media:
    • If your step is run before the computer has been booted into the installed OS (usually before execution of the Setup Windows and ConfigMgr step), this will be X:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe.
    • If your step is run after the computer has been booted into the installed OS (usually after execution of the Setup Windows and ConfigMgr step), this will be C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe.
  4. For the Command line field, type in the following, replacing PWSPath with the path to powershell.exe and ScriptName with the name of your script file. You can remove the -ExecutionPolicy Bypass bit if you have set up script signing.
    • ServiceUI.exe -Process:TSProgressUI.exe _PWSPath_ -NoProfile -WindowStyle Hidden -ExecutionPolicy Bypass -File _ScriptName_
  5. Check the Package option, and use the [Browse] button by it to browse to your package.
  6. Make any other modifications you need.

Non-Interactive Functions

  1. Add a Run PowerShell Script step to your task sequence, giving it an appropriate name and description.
  2. Pick Select a package with a PowerShell script, and use the [Browse] button to browse to your package.
  3. For Script Name, enter the name of your script.
  4. For PowerShell execution policy, pick Bypass, unless you have set up script signing (outside the scope of this article).
  5. Make any other modifications you need.