SCCM Task sequence Variable inside a Program

2.5k views Asked by At

I have a task sequence with multiple Variables that are stored on the objects themselves. Running a dump out of the variables when the TS executes looks fine and I can see all of the variables I have created. However, when I create a package with a program inside my TS I need to be able to call those same variables INSIDE the program.

Is this possible in any way to carry over TS variables into a program?

1

There are 1 answers

5
Syberdoor On BEST ANSWER

There is a COM Object "Microsoft.SMS.TSEnvironment" that can do this. So it depends mainly on the language your Program uses.

In VBScript it would be easy, e.g.:

Set smstsenv = CreateObject("Microsoft.SMS.TSEnvironment") 
strTSAdvID = smstsenv("_SMSTSAdvertID")

To get the Advertisement ID or

smstsenv.GetVariables

to get all Variables. Powershell would be equally trivial. C# or C++ should also be able to handle COM Objects. If your Language of choice does somehow not support them you could always wrap your program in a script, that reads the variable and passes it on, either as command line parameter or maybe set a normal windows environment variable with the same name,