question

NoblesJustinLukas-7531 avatar image
0 Votes"
NoblesJustinLukas-7531 asked ·

Updating Microsoft Endpoint Configuartion Manager (MECM) Tasksequenz via Powershell

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 :)


mem-cm-generalmem-cm-osd
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

GaryBlok avatar image
2 Votes"
GaryBlok answered ·

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



image.png (221.0 KiB)
image.png (204.3 KiB)
· 1 ·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks for your great reply. :)
I was using NewStepName instead of StepName wich caused all the variables to be changed... :D

0 Votes 0 ·