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








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