You are here:   Research
  |  Login

Welcome to my blog, quickest way to find articles is usually to search for them.

Minimize
Search in All Title Contents
 
     

Creating Task Sequences in ConfigMgr via PowerShell

Dec 07 2017

ConfigMgr 1710 has even more PowerShell cmdlets for creating and editing task sequences compared to ConfigMgr 1706.

34 more to be exact, growing them from 75 to 109 (including alias names because I was lazy :) ).

Tip: You might also want to check out some of the PowerShell samples from Ari Saastamoinen (@AriSaastamoinen) on his blog:  https://arisaastamoinencom.blogspot.fi/2017/08/sccm-ts-with-powershell.html

 

Sample

Here is a short sample to create a new custom task sequence with two groups, and two run command line actions:

 

# Create a new Task Sequence
$TS = New-CMTaskSequence -CustomTaskSequence -Name "Create TS Via PowerShell"

# Create the first group
$Group1 = New-CMTaskSequenceGroup -Name "First Group" 
Add-CMTaskSequenceStep -InsertStepStartIndex 0 -TaskSequenceName $TS.Name -Step $Group1

# Create the first Run Command Line action
$Step1 = New-CMTaskSequenceStepRunCommandLine -StepName "Run Command 1" -CommandLine "cmd.exe /c"
Set-CMTaskSequenceGroup -TaskSequenceName $TS.Name -StepName $Group1.Name -AddStep $Step1 -InsertStepStartIndex 0

# Create the second group
$Group2 = New-CMTaskSequenceGroup -Name "Second Group"
Add-CMTaskSequenceStep -InsertStepStartIndex 1 -TaskSequenceName $TS.Name -Step $Group2

# Create the second Run Command Line action
$Step2 = New-CMTaskSequenceStepRunCommandLine -StepName "Run Command 2" -CommandLine "cmd.exe /c"
Set-CMTaskSequenceGroup -TaskSequenceName $TS.Name -StepName $Group2.Name -AddStep $Step2 -InsertStepStartIndex 0

 

Result

Yep, here it is.

image
The resulting task sequence.

 

Written by Johan Arwidmark









Deployment News


Happy deployment, and thanks for reading!


What our lawyers makes us say:

This information is provided "AS IS" with no warranties, confers no rights and is not supported by the authors or Deployment Artist.

Copyright © 2017 by Deployment Artist (the company behind deployment research). All rights reserved. No part of the information on this web site may be reproduced or posted in any form or by any means without the prior written permission of the publisher.

Shorthand: Don't pass off our work as yours, it's not nice.

Blog Archive

Minimize




Where you can meet us!

Live Stream Recordings
ConfigMgr 1806 and W10 OSD

Windows 10 OSD Classes (US)
Dec 10, 2018, Chicago, US

Windows 10 OSD Classes (Europe)

Feb 4, 2019, Culemborg, The Netherlands

ConfigMgr CB Classes (US)
Jan 21, 2019, New York, US

Video-based trainings
https://online.truesec.com
https://deploymentartist.com/Training/Videos

MDT, Windows 10 and ConfigMgr Books
http://deploymentartist.com/Books

Contact Info
http://deploymentresearch.com/theteam