Jump to content
Sign in to follow this  
RayRay

Task Sequence variables in SCCM

Recommended Posts

RayRay

I'm trying to read a custom task sequence variable in a SCCM 2012 task sequence. Has anyone done this? I can do it in a vb script, just trying to port this to autoit so I can have more functionality.

VB looks like this:      set env = CreateObject("Microsoft.SMS.TSEnvironment")

                                  name = inputbox( prompt for name)

                                  env("OSDComputerName") = Name

Thanks for any help with this.

The vb code is just an example.

Edited by RayRay

Share this post


Link to post
Share on other sites
SSolheim

I think we finally found the one thing VBScript can do that AutoIT can't.  I ended up having AutoIT write a VBScript and then launch it.  It was a sad day: 

 $CompName = $Prefix & $Serial & $Suffix
 $TEMP = EnvGet("TEMP")
 $VBS_Path = $TEMP & "\NameComputer.vbs"
 $Line1 = 'Set env = CreateObject ( "Microsoft.SMS.TSEnvironment")' 
& @CRLF
 FileWrite($VBS_Path, $Line1)
 $Line1 = 'env ("OSDCOMPUTERNAME") = ' & $CompName & @CRLF
 FileWrite($VBS_Path, $Line1)
 $Result = ShellExecuteWait("cscript.exe", $VBS_Path)
 Exit($Result)

I also found that if I was using a 64bit PE then I had to compile a 64bit executable.  Apparently, WinPE doesn't support WOW.

Share this post


Link to post
Share on other sites
MaGRauN

I'm trying to read a custom task sequence variable in a SCCM 2012 task sequence. Has anyone done this? I can do it in a vb script, just trying to port this to autoit so I can have more functionality.

VB looks like this:      set env = CreateObject("Microsoft.SMS.TSEnvironment")

                                  name = inputbox( prompt for name)

                                  env("OSDComputerName") = Name

Thanks for any help with this.

The vb code is just an example.

 

Hello Rayray

Try this

$Var = "NAME OF VARIABLE"
$SCCM = ObjCreate("Microsoft.SMS.TSEnvironment")
$VarResult = $SCCM.Value($Var)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×