Updating Microsoft Endpoint Configuartion Manager (MECM) Tasksequenz via Powershell

Nobles, Justin 36 Reputation points
2021-03-03T13:50:39.587+00:00

Hello everyone,

I am currently trying to change several "Set Task Sequence Variable" steps in an already existing Task Sequenz. The issue I am facing:

Using Set-CMTSStepSetVariable - I couldn't pinpoint what step to set. Piping each object didn't do the job and i couldn't find a positional parameter to pass. Set seemed to always effect the entire TS.
Using Remove-CMTSStepSetVariable + Add-CMTaskSequenceStep - seemed as the most promising solution. To remove the "Set Task Sequence Variable" step i want to update and adding the new step with the new value. The problem here. How to find the correct place to add the new step? I was unable to retrieve the necessary information from the TS.

So in general my question would be: How to update Task Sequenz objects via powershell?
And more specific how to update "Set Task Sequence Variable" Values via Powershell?

Looking forward to hearing from you.
Best Regards Justin :)

Microsoft Configuration Manager Deployment
Microsoft Configuration Manager Deployment
Microsoft Configuration Manager: An integrated solution for for managing large groups of personal computers and servers.Deployment: The process of delivering, assembling, and maintaining a particular version of a software system at a site.
906 questions
Microsoft Configuration Manager
0 comments No comments
{count} votes

Accepted answer
  1. Gary Blok 1,736 Reputation points
    2021-03-04T00:04:02.57+00:00

    Example:

    $TSName = "Debug TSs Prov"  
      
      
    $NewCMStepVar = New-CMTaskSequenceStepSetVariable -TaskSequenceVariable "Hello" -TaskSequenceVariableValue "FALSE" -Name "New TS Var - Hello" -Description "Testing Vars via PowerShell"  
    Add-CMTaskSequenceStep -TaskSequenceName $TSName -Step $NewCMStepVar  
      
    Get-CMTaskSequence -Name $TSName | Set-CMTaskSequenceStepSetVariable -TaskSequenceVariable "Hello" -TaskSequenceVariableValue "TRUE" -StepName "New TS Var - Hello"  
    

    As long as you know the name of the step you want to update, should be pretty easy
    74023-image.png
    73993-image.png

    2 people found this answer helpful.

0 additional answers

Sort by: Most helpful