Hacking the Task Sequence - Schedschd.ws/hosted_files/mms2015/43/Hacking the Task Sequence...
Transcript of Hacking the Task Sequence - Schedschd.ws/hosted_files/mms2015/43/Hacking the Task Sequence...
![Page 1: Hacking the Task Sequence - Schedschd.ws/hosted_files/mms2015/43/Hacking the Task Sequence 2015.pdfHacking the Task Sequence 2015 Daniel Ratliff @potentengineer daniel.ratliff@gmail.com](https://reader034.fdocuments.us/reader034/viewer/2022052122/5aa1cce57f8b9a84398c2aff/html5/thumbnails/1.jpg)
Hacking the Task Sequence2015
Daniel Ratliff
@potentengineer
Mike Terrill
@miketerrill
![Page 2: Hacking the Task Sequence - Schedschd.ws/hosted_files/mms2015/43/Hacking the Task Sequence 2015.pdfHacking the Task Sequence 2015 Daniel Ratliff @potentengineer daniel.ratliff@gmail.com](https://reader034.fdocuments.us/reader034/viewer/2022052122/5aa1cce57f8b9a84398c2aff/html5/thumbnails/2.jpg)
#MMSMOA
@potentengineer
Technology Architect LouSMUG10+ years
Louisville, KY
Daniel Ratliff
![Page 3: Hacking the Task Sequence - Schedschd.ws/hosted_files/mms2015/43/Hacking the Task Sequence 2015.pdfHacking the Task Sequence 2015 Daniel Ratliff @potentengineer daniel.ratliff@gmail.com](https://reader034.fdocuments.us/reader034/viewer/2022052122/5aa1cce57f8b9a84398c2aff/html5/thumbnails/3.jpg)
#MMSMOA
@miketerrill
Product Manager AZSMUG18+ years
Phoenix, AZ
Mike Terrill
![Page 4: Hacking the Task Sequence - Schedschd.ws/hosted_files/mms2015/43/Hacking the Task Sequence 2015.pdfHacking the Task Sequence 2015 Daniel Ratliff @potentengineer daniel.ratliff@gmail.com](https://reader034.fdocuments.us/reader034/viewer/2022052122/5aa1cce57f8b9a84398c2aff/html5/thumbnails/4.jpg)
Goals of the Session
• Share ideas and experiences
• Provide tips and tricks
• Promote best practice ideas and new ways of solving problems
• Automate tasks from simple to daunting
• Have fun!
![Page 5: Hacking the Task Sequence - Schedschd.ws/hosted_files/mms2015/43/Hacking the Task Sequence 2015.pdfHacking the Task Sequence 2015 Daniel Ratliff @potentengineer daniel.ratliff@gmail.com](https://reader034.fdocuments.us/reader034/viewer/2022052122/5aa1cce57f8b9a84398c2aff/html5/thumbnails/5.jpg)
Agenda
• Overview
• Pausing the Task Sequence
• Listing & Setting Task Sequence Variables
• Set Dynamic Variables – hidden gem
• Documenting Task Sequence Classes
• Documenting Task Sequence Steps
• Adding/Removing Task Sequence Step
• Editing multiple Task Sequences
![Page 6: Hacking the Task Sequence - Schedschd.ws/hosted_files/mms2015/43/Hacking the Task Sequence 2015.pdfHacking the Task Sequence 2015 Daniel Ratliff @potentengineer daniel.ratliff@gmail.com](https://reader034.fdocuments.us/reader034/viewer/2022052122/5aa1cce57f8b9a84398c2aff/html5/thumbnails/6.jpg)
Overview
Hack [hak]“To devise or modify (a computer program), usually skillfully.”
-Dictionary.com
![Page 7: Hacking the Task Sequence - Schedschd.ws/hosted_files/mms2015/43/Hacking the Task Sequence 2015.pdfHacking the Task Sequence 2015 Daniel Ratliff @potentengineer daniel.ratliff@gmail.com](https://reader034.fdocuments.us/reader034/viewer/2022052122/5aa1cce57f8b9a84398c2aff/html5/thumbnails/7.jpg)
Task Sequence Variables
![Page 8: Hacking the Task Sequence - Schedschd.ws/hosted_files/mms2015/43/Hacking the Task Sequence 2015.pdfHacking the Task Sequence 2015 Daniel Ratliff @potentengineer daniel.ratliff@gmail.com](https://reader034.fdocuments.us/reader034/viewer/2022052122/5aa1cce57f8b9a84398c2aff/html5/thumbnails/8.jpg)
Always include certain files in your Boot Images
• Put CMTrace.exe in the path• SMSTS.INI• Company background image• ServiceUI.exe• Other scripts or utilities that do not change often
NOTE: Keep them small so you do not bloat the size of the boot image
Future upgrades and service packs may overwrite changes
See References for blog link
![Page 9: Hacking the Task Sequence - Schedschd.ws/hosted_files/mms2015/43/Hacking the Task Sequence 2015.pdfHacking the Task Sequence 2015 Daniel Ratliff @potentengineer daniel.ratliff@gmail.com](https://reader034.fdocuments.us/reader034/viewer/2022052122/5aa1cce57f8b9a84398c2aff/html5/thumbnails/9.jpg)
Pausing the Task Sequence
Interactive cmd prompt with cmd
cmd.exe /c "start /wait cmd.exe"
Interactive cmd prompt using ServiceUI (e.g. under
old OS of a Refresh build)
"%toolroot%\ServiceUI.exe" -process:tsprogressui.exe
"%WINDIR%\System32\cmd.exe"
![Page 10: Hacking the Task Sequence - Schedschd.ws/hosted_files/mms2015/43/Hacking the Task Sequence 2015.pdfHacking the Task Sequence 2015 Daniel Ratliff @potentengineer daniel.ratliff@gmail.com](https://reader034.fdocuments.us/reader034/viewer/2022052122/5aa1cce57f8b9a84398c2aff/html5/thumbnails/10.jpg)
Pausing the Task Sequence – On Content Steps
Use SMSTSDownloadProgram to Pause the Task
Sequence:
Set Task Sequence Variable SMSTSDownloadProgram to either:
Baremetal:
cmd.exe /c "start /wait cmd.exe"
Refresh:
"%WINDIR%\ServiceUI.exe" -process:tsprogressui.exe
"%WINDIR%\System32\cmd.exe"
(Make it simple and copy the correct platform version of
ServiceUI.exe to %WINDIR% on test system and Boot Image)
![Page 11: Hacking the Task Sequence - Schedschd.ws/hosted_files/mms2015/43/Hacking the Task Sequence 2015.pdfHacking the Task Sequence 2015 Daniel Ratliff @potentengineer daniel.ratliff@gmail.com](https://reader034.fdocuments.us/reader034/viewer/2022052122/5aa1cce57f8b9a84398c2aff/html5/thumbnails/11.jpg)
Listing Task Sequence Variables
Can be done with a simple VBScript:
Set osdvars=createobject("Microsoft.SMS.TSEnvironment")
For each var in osdvars.getvariables
Wscript.echo var & "=" & osdvars(var)
Next
![Page 12: Hacking the Task Sequence - Schedschd.ws/hosted_files/mms2015/43/Hacking the Task Sequence 2015.pdfHacking the Task Sequence 2015 Daniel Ratliff @potentengineer daniel.ratliff@gmail.com](https://reader034.fdocuments.us/reader034/viewer/2022052122/5aa1cce57f8b9a84398c2aff/html5/thumbnails/12.jpg)
Listing Task Sequence Variables
Can be done with PowerShell:
$tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment
$tsenv.GetVariables() | % { Write-Host "$_ = $($tsenv.Value($_))" }
Requires PowerShell and .Net Framework components in the Boot Image
Boot Image size goes from ~260 MB to ~375 MB
![Page 13: Hacking the Task Sequence - Schedschd.ws/hosted_files/mms2015/43/Hacking the Task Sequence 2015.pdfHacking the Task Sequence 2015 Daniel Ratliff @potentengineer daniel.ratliff@gmail.com](https://reader034.fdocuments.us/reader034/viewer/2022052122/5aa1cce57f8b9a84398c2aff/html5/thumbnails/13.jpg)
Listing & Setting Task Sequence Variables
Or it can be done with TSEnv2 (available to
1E Nomad customers):
TSEnv2.exe list
TSEnv2.exe list > osdvars.txt
TSEnv2.exe get _SMSTSMDataPath
![Page 14: Hacking the Task Sequence - Schedschd.ws/hosted_files/mms2015/43/Hacking the Task Sequence 2015.pdfHacking the Task Sequence 2015 Daniel Ratliff @potentengineer daniel.ratliff@gmail.com](https://reader034.fdocuments.us/reader034/viewer/2022052122/5aa1cce57f8b9a84398c2aff/html5/thumbnails/14.jpg)
Set Dynamic Variables – Hidden Gem
Available starting with ConfigMgr 2012 R2
Adds:
_SMSTSMake
_SMSTSModel
_SMSTSMacAdresses (not Addresses)
_SMSTSIPAddresses
_SMSTSDefaultGateWays
_SMSTSSerialNumber
_SMSTSAssetTag
_SMSTSUUID
![Page 15: Hacking the Task Sequence - Schedschd.ws/hosted_files/mms2015/43/Hacking the Task Sequence 2015.pdfHacking the Task Sequence 2015 Daniel Ratliff @potentengineer daniel.ratliff@gmail.com](https://reader034.fdocuments.us/reader034/viewer/2022052122/5aa1cce57f8b9a84398c2aff/html5/thumbnails/15.jpg)
Task Sequence Variables & x64 Boot Images
• Microsoft.SMS.TSEnvironment is not available between Pre-start & Running Task Sequence
• Normally this is not a problem – but for testing Prestart development it can be
• Solution – launch a cmd /k from Prestart and the TSEnvironment will be available
• See DeploymentRamblings blog for more information
![Page 16: Hacking the Task Sequence - Schedschd.ws/hosted_files/mms2015/43/Hacking the Task Sequence 2015.pdfHacking the Task Sequence 2015 Daniel Ratliff @potentengineer daniel.ratliff@gmail.com](https://reader034.fdocuments.us/reader034/viewer/2022052122/5aa1cce57f8b9a84398c2aff/html5/thumbnails/16.jpg)
DemoTask Sequence Variables
![Page 17: Hacking the Task Sequence - Schedschd.ws/hosted_files/mms2015/43/Hacking the Task Sequence 2015.pdfHacking the Task Sequence 2015 Daniel Ratliff @potentengineer daniel.ratliff@gmail.com](https://reader034.fdocuments.us/reader034/viewer/2022052122/5aa1cce57f8b9a84398c2aff/html5/thumbnails/17.jpg)
Documenting Task Sequences
![Page 18: Hacking the Task Sequence - Schedschd.ws/hosted_files/mms2015/43/Hacking the Task Sequence 2015.pdfHacking the Task Sequence 2015 Daniel Ratliff @potentengineer daniel.ratliff@gmail.com](https://reader034.fdocuments.us/reader034/viewer/2022052122/5aa1cce57f8b9a84398c2aff/html5/thumbnails/18.jpg)
Export-CMTaskSequenceStepClasses
• Creates reference .csv for all iResultObject classes
• Identifies all properties specific to each class• e.g, RunCommandLine, PackageID, ProgramName
• Identifies all property types• e.g, Boolean, string, int32, array
• Used to build all functions in CMTaskSequenceEditor.psm1
![Page 19: Hacking the Task Sequence - Schedschd.ws/hosted_files/mms2015/43/Hacking the Task Sequence 2015.pdfHacking the Task Sequence 2015 Daniel Ratliff @potentengineer daniel.ratliff@gmail.com](https://reader034.fdocuments.us/reader034/viewer/2022052122/5aa1cce57f8b9a84398c2aff/html5/thumbnails/19.jpg)
Export-CMTaskSequenceStepClasses output
![Page 20: Hacking the Task Sequence - Schedschd.ws/hosted_files/mms2015/43/Hacking the Task Sequence 2015.pdfHacking the Task Sequence 2015 Daniel Ratliff @potentengineer daniel.ratliff@gmail.com](https://reader034.fdocuments.us/reader034/viewer/2022052122/5aa1cce57f8b9a84398c2aff/html5/thumbnails/20.jpg)
Old hat - Task Sequence Documentor v2
![Page 21: Hacking the Task Sequence - Schedschd.ws/hosted_files/mms2015/43/Hacking the Task Sequence 2015.pdfHacking the Task Sequence 2015 Daniel Ratliff @potentengineer daniel.ratliff@gmail.com](https://reader034.fdocuments.us/reader034/viewer/2022052122/5aa1cce57f8b9a84398c2aff/html5/thumbnails/21.jpg)
New hat – Get-CMTaskSequenceSteps
![Page 22: Hacking the Task Sequence - Schedschd.ws/hosted_files/mms2015/43/Hacking the Task Sequence 2015.pdfHacking the Task Sequence 2015 Daniel Ratliff @potentengineer daniel.ratliff@gmail.com](https://reader034.fdocuments.us/reader034/viewer/2022052122/5aa1cce57f8b9a84398c2aff/html5/thumbnails/22.jpg)
Comparison
Task Sequence Documentor v2 Get-CMTaskSequenceSteps
Output XML stylesheet (.xml + .xsl) Comma-separated value file (.csv)
Output modification Limited to stylesheet modification for
formatting
Limited only by PowerShell & Excel
Editable content Not easily, requires .xml modification Yes, object based input
Steps indexed No Yes, in consecutive order
Shareable Yes, with instructions. Can only be
displayed in Internet Explorer.
Yes, just a .csv file
![Page 23: Hacking the Task Sequence - Schedschd.ws/hosted_files/mms2015/43/Hacking the Task Sequence 2015.pdfHacking the Task Sequence 2015 Daniel Ratliff @potentengineer daniel.ratliff@gmail.com](https://reader034.fdocuments.us/reader034/viewer/2022052122/5aa1cce57f8b9a84398c2aff/html5/thumbnails/23.jpg)
Get-CMTaskSequenceSteps notes
Gotchyas!• Still in development!
• TS steps with multiple if conditions are not documented properly (multiple conditions with a single if statement work fine)
• Nested groups are not displayed as nested
• Some passwords are plain text! (MDT Configure ADDS)
![Page 24: Hacking the Task Sequence - Schedschd.ws/hosted_files/mms2015/43/Hacking the Task Sequence 2015.pdfHacking the Task Sequence 2015 Daniel Ratliff @potentengineer daniel.ratliff@gmail.com](https://reader034.fdocuments.us/reader034/viewer/2022052122/5aa1cce57f8b9a84398c2aff/html5/thumbnails/24.jpg)
DemoDocumenting TS steps
![Page 25: Hacking the Task Sequence - Schedschd.ws/hosted_files/mms2015/43/Hacking the Task Sequence 2015.pdfHacking the Task Sequence 2015 Daniel Ratliff @potentengineer daniel.ratliff@gmail.com](https://reader034.fdocuments.us/reader034/viewer/2022052122/5aa1cce57f8b9a84398c2aff/html5/thumbnails/25.jpg)
Editing Task Sequences
![Page 26: Hacking the Task Sequence - Schedschd.ws/hosted_files/mms2015/43/Hacking the Task Sequence 2015.pdfHacking the Task Sequence 2015 Daniel Ratliff @potentengineer daniel.ratliff@gmail.com](https://reader034.fdocuments.us/reader034/viewer/2022052122/5aa1cce57f8b9a84398c2aff/html5/thumbnails/26.jpg)
Add-CMTaskSequenceStep
• Adds a step to a task sequence at the specified index
• If no index is specified step is added to end of TS
• Accounts for the following step types• Run Command Line
• Install Package
• Install Application
• Group
• Use step index from Get-CMTaskSequenceSteps output
![Page 27: Hacking the Task Sequence - Schedschd.ws/hosted_files/mms2015/43/Hacking the Task Sequence 2015.pdfHacking the Task Sequence 2015 Daniel Ratliff @potentengineer daniel.ratliff@gmail.com](https://reader034.fdocuments.us/reader034/viewer/2022052122/5aa1cce57f8b9a84398c2aff/html5/thumbnails/27.jpg)
Add-CMTaskSequenceStep examples
Add-CMTaskSequenceStep -SiteServer CM01 -SiteCode CM1 -TaskSequencePackageIDCM10001B -StepType RunCommandLine -Name "Run a command" -CommandLine "cmd /c md c:\temp"
This example creates a Run Command Line step with the default parameters
Add-CMTaskSequenceStep -SiteServer CM01 -SiteCode CM1 -TaskSequencePackageIDCM10001B -StepType RunCommandLine -Name "Run a command" -CommandLine "cmd /c md c:\temp" -StepIndex 8
This example creates a Run Command Line step with the default parameters as the
8th step in the task sequence
![Page 28: Hacking the Task Sequence - Schedschd.ws/hosted_files/mms2015/43/Hacking the Task Sequence 2015.pdfHacking the Task Sequence 2015 Daniel Ratliff @potentengineer daniel.ratliff@gmail.com](https://reader034.fdocuments.us/reader034/viewer/2022052122/5aa1cce57f8b9a84398c2aff/html5/thumbnails/28.jpg)
Add-CMTaskSequenceStep notes
Gotchyas!• Still in development, lots of functionality to be added in time
• Does not check if task sequence is open (read-only)
• Cannot add conditions
• Does not account for all task sequence steps
• Install Application step cannot add multiple Apps easily (array of apps are required)
![Page 29: Hacking the Task Sequence - Schedschd.ws/hosted_files/mms2015/43/Hacking the Task Sequence 2015.pdfHacking the Task Sequence 2015 Daniel Ratliff @potentengineer daniel.ratliff@gmail.com](https://reader034.fdocuments.us/reader034/viewer/2022052122/5aa1cce57f8b9a84398c2aff/html5/thumbnails/29.jpg)
Remove-CMTaskSequenceStep
• Removes a step to a task sequence at the specified index
• Does not remove groups by default
• Use –force to remove a group and all child steps
• Use step index from Get-CMTaskSequenceSteps output
![Page 30: Hacking the Task Sequence - Schedschd.ws/hosted_files/mms2015/43/Hacking the Task Sequence 2015.pdfHacking the Task Sequence 2015 Daniel Ratliff @potentengineer daniel.ratliff@gmail.com](https://reader034.fdocuments.us/reader034/viewer/2022052122/5aa1cce57f8b9a84398c2aff/html5/thumbnails/30.jpg)
Remove-CMTaskSequenceStep examples
Remove-CMTaskSequenceStep -SiteServer CM01 -SiteCode CM1 `
-TaskSequencePackageID CM10000A -StepIndex 5
This example removes the 5th step in the task sequence
Remove-CMTaskSequenceStep -SiteServer CM01 -SiteCode CM1 `
-TaskSequencePackageID CM10000A -StepIndex 4 -Force
This example removes the 4th step in the task sequence and forces removal if
the step is a group
![Page 31: Hacking the Task Sequence - Schedschd.ws/hosted_files/mms2015/43/Hacking the Task Sequence 2015.pdfHacking the Task Sequence 2015 Daniel Ratliff @potentengineer daniel.ratliff@gmail.com](https://reader034.fdocuments.us/reader034/viewer/2022052122/5aa1cce57f8b9a84398c2aff/html5/thumbnails/31.jpg)
Remove-CMTaskSequenceStep notes
Gotchyas!•Still in development, lots of functionality to be added in time
•Does not prompt for removing large groups
•Cannot remove steps nested below 2 or more groups
![Page 32: Hacking the Task Sequence - Schedschd.ws/hosted_files/mms2015/43/Hacking the Task Sequence 2015.pdfHacking the Task Sequence 2015 Daniel Ratliff @potentengineer daniel.ratliff@gmail.com](https://reader034.fdocuments.us/reader034/viewer/2022052122/5aa1cce57f8b9a84398c2aff/html5/thumbnails/32.jpg)
DemoAdding/removing TS steps
![Page 33: Hacking the Task Sequence - Schedschd.ws/hosted_files/mms2015/43/Hacking the Task Sequence 2015.pdfHacking the Task Sequence 2015 Daniel Ratliff @potentengineer daniel.ratliff@gmail.com](https://reader034.fdocuments.us/reader034/viewer/2022052122/5aa1cce57f8b9a84398c2aff/html5/thumbnails/33.jpg)
Module: CMTaskSequenceEditor.psm1
Import-Module '.\CMTaskSequenceEditor.psm1'
• Still in development, lots of functionality to be added in time
• Includes the following functions:
• Export-CMTaskSequenceStepClasses
• Get-CMTaskSequenceSteps
• Add-CMTaskSequenceStep
• Remove-CMTaskSequenceStep
• Future functions
• Move-CMTaskSequenceStep (Move an existing step)
• Set-CMTaskSequenceStep (Edit an existing step)
• Will be available on TechNet gallery after MMS
![Page 34: Hacking the Task Sequence - Schedschd.ws/hosted_files/mms2015/43/Hacking the Task Sequence 2015.pdfHacking the Task Sequence 2015 Daniel Ratliff @potentengineer daniel.ratliff@gmail.com](https://reader034.fdocuments.us/reader034/viewer/2022052122/5aa1cce57f8b9a84398c2aff/html5/thumbnails/34.jpg)
Other Sessions
• Automating End To End Image Creation with MDT and PowerShell (Tuesday, November 10th at 2:00 PM)
• Real World Windows Deployments with Dell & 1E (Monday, November 9th at 1:00 PM)
• Making the switch from BIOS to UEFI (Wednesday, November 11th at 4:00 PM)
• MMS Every Month at Home – User Groups (Wednesday, November 11th at 6:00 PM)
![Page 35: Hacking the Task Sequence - Schedschd.ws/hosted_files/mms2015/43/Hacking the Task Sequence 2015.pdfHacking the Task Sequence 2015 Daniel Ratliff @potentengineer daniel.ratliff@gmail.com](https://reader034.fdocuments.us/reader034/viewer/2022052122/5aa1cce57f8b9a84398c2aff/html5/thumbnails/35.jpg)
References
• Task Sequence Documentor• Task Sequence Documentor v2• Using the Task Sequence Documentor with PowerShell
• Task Sequence Editing community resources• Ben Burckart – Adding a step to a task sequence - PowerShell• TechNet forums – Adding a step to a task sequence - PowerShell• J. Greg – OSD Driver handling in a task sequence - PowerShell• Nigel Wright – Adding a step to a task sequence – SDK
• Microsoft resources• ConfigMgr 2012 R2 SDK download• MSDN - OSD Task Sequence SDK• MSDN - OSD WMI Classes SDK
![Page 36: Hacking the Task Sequence - Schedschd.ws/hosted_files/mms2015/43/Hacking the Task Sequence 2015.pdfHacking the Task Sequence 2015 Daniel Ratliff @potentengineer daniel.ratliff@gmail.com](https://reader034.fdocuments.us/reader034/viewer/2022052122/5aa1cce57f8b9a84398c2aff/html5/thumbnails/36.jpg)
References
• ConfigMgr 2012: Always including certain files in your Boot Images
• Task Sequence Built-in Variables in Configuration Manager
• WinPE 5.0 x64: Microsoft.SMS.TSEnvironmentUnavailable?
• 1E Free Tools
![Page 37: Hacking the Task Sequence - Schedschd.ws/hosted_files/mms2015/43/Hacking the Task Sequence 2015.pdfHacking the Task Sequence 2015 Daniel Ratliff @potentengineer daniel.ratliff@gmail.com](https://reader034.fdocuments.us/reader034/viewer/2022052122/5aa1cce57f8b9a84398c2aff/html5/thumbnails/37.jpg)
Blogs
• www.potentengineer.com
• miketerrill.net
![Page 38: Hacking the Task Sequence - Schedschd.ws/hosted_files/mms2015/43/Hacking the Task Sequence 2015.pdfHacking the Task Sequence 2015 Daniel Ratliff @potentengineer daniel.ratliff@gmail.com](https://reader034.fdocuments.us/reader034/viewer/2022052122/5aa1cce57f8b9a84398c2aff/html5/thumbnails/38.jpg)
Evaluations: Please provide session feedback by clicking the EVAL button in the scheduler app (also
download slides). One lucky winner will receive a free ticket to the next MMS!
Hacking the Task Sequence 2015
Discuss…
Ask your questions-real world answers!
Plenty of time to engage, share knowledge.
SPONSORS
![Page 39: Hacking the Task Sequence - Schedschd.ws/hosted_files/mms2015/43/Hacking the Task Sequence 2015.pdfHacking the Task Sequence 2015 Daniel Ratliff @potentengineer daniel.ratliff@gmail.com](https://reader034.fdocuments.us/reader034/viewer/2022052122/5aa1cce57f8b9a84398c2aff/html5/thumbnails/39.jpg)