Task Sequence Powershell Module

Awhile ago I submitted a request to Microsoft for a built-in Powershell Module during the Task Sequence. Mostly for basic things like getting and setting variables, but once I noticed what all the COM Objects exposed, I wanted to take this a step further.

Primarily you’ll have 2 COM objects you can create during a Task Sequence: Microsoft.SMS.TSEnvironment (getting/setting variables) and Microsoft.SMS.TSProgressUI (manipulating the Progress and messages). I’ve uploaded the module for you all to use at my github. I’ll run though some of the details below including visuals for the TSProgressUI items. Some, if not most, of these are-for lack of a more appropriate label-useless; but can still be fun to mess around with!




This function is not exported, as it is used within the module to verify that the Microsoft.SMS.TSEnvironment COM Object is loaded before attempting any operations.


Calls “GetVariables()” on the COM Object. This will return an array of all Task Sequence Variable NAMES only.


Calls “Value()” on the COM Object to return the value of a specific variable. the “Name” Parameter should be the Task Sequence Variable you want the value for.


Assigns a value to a specific variable. A Boolean return indicates success. Note this is wrapped in a try/catch in the event you attempt to set a read-only variable.


Returns an object of all Task Sequence Variables and their assigned Values.



This function is not exported, as it is used within the module to verify that the Microsoft.SMS.TSProgressUI COM Object is loaded before attempting any operations.


Calls “ShowActionProgress()” on the COM object. This is the function I use 99.9% of the time for UI related actions. This will add the “second” progress bar and update the Text for that progress bar as well as fill the progress meter as you see fit. The neat thing here, is that the “Step” and “MaxStep” will automatically show a “100%” representation. For example, if i have 8 of 400 complete, I don’t have to do the extra scripting to pass in “2” and “100”. I can pass in 8, and 400, and the COM Object does the math for us.

There are other parameters here with “ShowActionProgress()”. With this function, those use the built-in variables “designed” to be used here. If you want to extend this function to allow those additional parameters, feel free. Personally, I don’t find them useful enough to include.

Step Param set to 5, MaxStep Param set to 10.


Calls “CloseProgressDialog()” on the COM object. Closes or “hides” the progress bar window. This will automatically reappear once the current step has completed, or if you call one of the “show” functions for the UI.


Calls “ShowTSProgress” on the COM object. This function manipulates the “Top part” of the progress bar. If, for whatever reason, you wanted to manipulate the progress bar without adding the “second/bottom” bar, this is what you should use.

Step Param set to 5, MaxStep Param set to 10.


Calls “ShowErrorDialog()” on the COM object. This wills how the typical “Error in the Task Sequence” Window. There are parameters for the error title, error message/details, exit code, a timeout, and a force reboot. The force reboot will trigger a reboot after the timeout (in seconds) has expired.



Calls “ShowMessage()” on the COM Object. This essentially shows a MessageBox allowing you to specify the button configuration. The interesting (and somewhat useless) part of this, is that you do not receive a return value. If you want a simple “OK” message box, this should work, otherwise I’d recommend using a Normal MessageBox.

Button Options (Type Parameter):

  • 0 = OK
  • 1 = OK, Cancel
  • 2 = Abort, Retry, Ignore
  • 3 = Yes, No, Cancel
  • 4 = Yes, No
  • 5 = Retry, Cancel
  • 6 = Cancel, Try Again, Continue

Type Param set to 0.


Calls “ShowRebootDialog()” on the COM Object. This will allow you to present a custom reboot window. I would recommend against this, as untimely reboots during a task sequence can cause some issues. This is essentially what causes the issue where Updates cause Double Reboots during OSD. If you do need a reboot after a step, either inset a restart computer step in your task sequence or just have your script exit “3010”.

Typically OrganzationName will use the TS Variable “_SMSTSOrgName”.


Calls “ShowSwapMediaDialog()” on the COM Object. If you’ve ever used standalone media that was broken up into multiple CD/DVD sets (or played a Final Fantasy on Playstation), you’ve seen this one. This is a message indicating for you to swap media, letting you know what disk number to insert.




Windows 10 Upgrade: Using USMT Hardlink

For those of us who have 32-bit Versions of Windows (whatever) floating around, you may have noticed that a lot of Hardware OEM’s are no longer providing 32-bit drivers for Windows 10. This creates an issue if/when you want to get those devices up to Windows 10. The In-Place Upgrade options built into the Windows 10 setup is amazing! However, it does not support 32-bit to 64-bit upgrade. Your best bet to getting this upgraded is to use whats called a USMT Hardlink and upgrade the OS.

What is USMT Hardlink?

USMT (User State Migration Tool) is a nice utility from Microsoft that is used to migrate a user profile from one operating system to the next. A USMT Hardlink deployment refers to a Windows OS Deployment (to the same hardware) where we’ll create a local offline copy of the user profile, apply the new OS (without cleaning the disk) and then injecting the user profile back to that machine. In the situation of say Windows XP to Windows 7, USMT Hardlink was our only option (As there was no In-Place Upgrade). The same goes for a 32-bit verions of Windows-whatever (7,8,8.1) to Windows 10 64-bit.

One thing to mention: Microsoft requires that for Windows 10 deployments, you have the appropriate Service Pack Installed. Now it is possible to do this without the Service Pack using a few small steps. I’ll include those steps with the process, look for “Without Service Pack“. If you do not have the Service Pack installed, you will need a system that has the Windows 10 ADK installed. We’ll need to pull some files and make some packages using that media.

Create the Task Sequence

  1. Once created, we’ll be deleting the whole thing, I’m running through this with you in case you need a Boot Image, MDT Package, USMT Package, or custom package created as this wizard will help you create those. If you already have these packages, feel free to create a custom Task Sequence and skip ahead.
  2. Make sure you have MDT 2013 installed with the ConfigMgr Integration setup, as well as the Windows ADK!
    Open the SCCM Console, Navigate to the Software Library Node, Expand Operating Systems.
  3. Right click “Task Sequence” and select “Create MDT Task Sequence”
  4. Select “Client Replace Task Sequence” and click Next.
  5. Name your task sequence appropriately, “Windows 10 64-bit (Hardlink)” works for me!
  6. Boot Image: Specify an existing or create a new.

    1. Without Service Pack: You’ll need a WinPE Image from the Windows 10 ADK which cannot be done 100% without the Service Pack. Specify whatever boot image you have for now. We’ll fix this later!
  7. MDT Package: Specify an existing package or create a new.
  8. USMT Package: Specify an existing package or create a new one.
    Without Service Pack: On the machine with the Windows 10 ADK Installed, copy the following folder to the network and use this source to create your USMT Package: “C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\User State Migration Tool
  9. Settings Package: Specify and existing or create a new. I use the vanilla Custom Settings Package for this; I’ll assume you are too.
  10. Review the Summary, and complete the wizard.


Boot Image:

If you’re running 2012 R2 SP1 (or 2012 SP2), then you should have the Windows 10 ADK installed on your server so new Boot Media should be a breeze. If, however, you do NOT have the Service Pack installed, a Win10 WinPE Boot media image CAN be imported and used, you just can’t modify it:

Boot Media with SCCM Service Pack:


Boot Media without SCCM Service Pack. Notice we’re missing some key tabs:


The solution here, is to create the Boot Media, then import the customized WIM file. Rather than provide instructions, I’ll direct you over to the best of the best: Johan Arwidmark. Follow his tutorial to create your custom WinPE.wim, then import directly into SCCM.

MDT Package:

Right now there isn’t a MDT version released with Windows 10 Support, However, I’ve been successful using the Toolkit Package from MDT 2013 as well as the Preview MDT that has been released.

USMT Package:

For your USMT Package, you’ll need to use what comes with the Windows 10 ADK. Install the Windows 10 ADK on any system then copy the following folder to the network and use this as the package source to create your USMT Package: “C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\User State Migration Tool“. Your package source must match the folders structure! You package source will have 3 folders: amd64, arm64, x86. If you have custom xml files to use with USMT, place them in the appropriate folder for the architecture of the OS.

Operating System Image

If you don’t already have SCCM 2012 R2 SP1 (2012 SP2) to create a proper Build and Capture, you can simply import the install.wim into SCCM under “Operating System Images”. Point directly to the install.wim inside the sources folder.

Reference the Boot Media

If a boot media is not referenced, a Restart Computer step cannot select the assigned Boot Media. It’s good to have this setup ahead of time, so all steps can be properly configured.

  1. Right-Click your Task Sequence and select Properties.
  2. Verify “Use a boot image” is checked.
  3. Click Browse and select the Windows 10 WinPE Image you have.
    1. If you want, you can add options to set only on specific Operating Systems. This will help prevent the wrong Client Operating System from running the deployment.
  4. Click OK.

Customize the Task Sequence

  1. Edit the Task Sequence.
  2. Now, If you ran through the wizard creating the Task Sequence, Remove all steps! Yes, All of them!
  3. Create a Folder called “Initialization”
    1. Within this group we’ll create 3 built in steps
      1. MDT> Use Toolkit Package
        1. Specify the packages you created for the Toolkit Package
      2. MDT> Gather
        1. Specify the packages your Custom Settings Package for Gather if you desire. I use “Gather only local data…”.
      3. General> Check Readiness
        1. Set “Ensure minimum memory (MB)” 2048 (you may adjust higher if you see fit)
        2. “Ensure minimum processor speed (MHz)” I left at the default (800)
        3. Verify “Ensure minimum free disk space (MB)” is at least 6000 (6GB).
        4. Verify “Ensure current OS to be refreshed is” is set to “Client”.
  4. Below those steps, add a folder called “Capture User State and Settings”. Within here we’ll have 6 steps in this order:
    1. General> Run Command Line
      1. Name: Capture Groups
      2. Command line: cscript.exe “%deployroot%\Scripts\ZTIGroups.wsf” /capture
    2. Settings> Capture Network Settings
      1. Check both options “Migrate domain…” and “Migrate network…”
    3. Settings> Capture Windows Settings
      1. Check all options “Migrate computer name”, “Migrate Registered user and organization names” and “Migrate time zone”
    4. General> Set Task Sequence Variable
      1. Name: “Set User State Store Path”
      2. Task Sequence Variable: OSDStateStorePath
      3. Value: %SystemDrive%\UserState
    5. General> Set Task Sequence Variable
      1. Name: Set USMT Additional Capture Options
      2. Task Sequence Variable: OSDMigrateAdditionalCaptureOptions
      3. The Value can be any mix of USMT capture arguments. Please note with the Windows 10 USMT Package, you do not need to specify the /hardlink parameter. I use the following:
        1. Value: /uel:90 /ui:DOMAIN\*
        2. This migrates all domain profiles that have been used in the last 90 days.
        3. Make sure to replace “DOMAIN” with your domain!
    6. User State> Capture User State
      1. Specify your Windows 10 USMT Package
      2. If you have custom capture files, be sure to specify those using the “Customize how user profiles are captured”
      3. In my example, I left “Enable verbose logging” and “Skip…EFS” unchecked
      4. Select “Copy by using file system access”
        1. “Continue if some files cannot be captures” is Checked
        2. “Capture locally by using links instead of by copying files” is Checked
  5. Create a new group called “Install Operating System”. We’ll have 8 steps in this order:
    1. General> Restart Computer
      1. Name: “Restart in Windows PE”
      2. Select “The boot image assigned to this task sequence”
      3. User notification is recommended in this case, so feel free to specify a friendly message for the user.
    2. MDT> Use Toolkit Package:
      1. Specify your MDT Package
    3. MDT> Gather
      1. Specify your Custom Settings package if you desire. I use “Gather only local data…”.
    4. Images> Apply Operating System
      1. Specify your Windows 10 Image
      2. If you have an answer file, specify that. I don’t use one here.
      3. Verify the Destination is set to “Next available formatted partition”
    5. Settings> Apply Windows Settings
      1. Specify your org information, local admin, and time zone settings as a good fallback if the captured settings cannot be used.
    6. Settings> Apply Network Settings
      1. If you’ll be upgrading a domain computer, make sure to specify the Domain and Account. Since we’ll be using the captured settings, we don’t need to specify a Domain OU.
    7. MDT> Gather
      1. Specify your Custom Settings package if you desire. I use “Gather only local data…”.
    8. General> Run Command Line
      1. Name: Configure
      2. Command line: cscript.exe “%deployroot%\Scripts\ZTIConfigure.wsf”
  6. Create a folder called “Apply Drivers”
    1. You can either use the Auto Apply or specify a Driver package. If you’re using driver packages make sure to filter any hardware specific information on each step.
  7. Create a folder called “Setup Operating System”. We’ll have 4 steps in this order:
    1. Images> Setup Windows and Configuration Manager.
      1. Specify your Package for the Configuration Manager Client
      2. Without Service Pack: add the following in the “Installation Properties”: /skipprereq:windowsupdateagent30-x64.exe
    2. General> Restart Computer
      1. “The currently installed default operating system”
      2. At this point its not necessary to provide notification.
    3. MDT> Use Toolkit Package
      1. Specify your MDT Package
    4. MDT> Gather
      1. Specify your Custom Settings package if you desire. I use “Gather only local data…”.
  8. Create a folder called “Software Installation”
    1. Here is where you’d put a list of software to install within your image. For us, this is where we place our standard Corporate Applications.
  9. Create a folder called “Install Software Updates”
    1. Typically we’ll have 3 repeated steps of “Install Software Updates”. If you are only deploying the OS, one should be enough, however, if you’re deploying software like “Office”, it may be wise to have 2 or 3 just to make sure all gets applied. At this time I only have one cycle:
      1. General> Install Software Updates
        1. All Software Updates
      2. General> Restart Computer
        1. “The Current Default Operating System”
        2. Notification is not necessary.
  10. Create a folder called “Restore User Files and Settings”. We’ll have the following 5 steps:
    1. MDT> User Toolkit Package
      1. Specify your MDT Package
    2. General> Run Command Line
      1. Name: Restore Groups
      2. Command line: cscript.exe “%deployroot%\Scripts\ZTIGroups.wsf” /restore
    3. General> Set Task Sequence Variable
      1. Name: Set USMT Additional Restore Options
      2. Task Sequence Variable: OSDMigrateAdditionalRestoreOptions
      3. Value: /uel:90 /ui:DOMAIN\*
    4. User State> Restore User Files and Settings
      1. Specify your USMT Package
      2. If you used custom xml files to capture user profiles, you’ll need to specify them again here for the restore.
      3. If you desire to restore local profiles, check the box
      4. Check “Continue if some files cannot be restored”.
    5. General> Restart Computer
      1. “The currently installed default operating system”
  11. And that’s it!


  1. Distribute your package references:
    1. Right Click the Task Sequence and select “Distribute Content”.
    2. Run through the wizard selecting any Distribution Points or Distribution Point Groups.
  2. If you don’t already, make sure you have a Collection setup to deploy to!
  3. Right Click the Task Sequence and select “Deploy”,
    1. Select your Collection and complete the Wizard.
  4. Update Machine Policy on the client.
  5. Watch Software Center
  6. Click Install and wait.
  7. Once all is done, We’re at Windows 10 64-bit!