none
[SCCM 2012] Microsoft.SMS.TSEnvironment does NOT work in Task Sequence as part of VB or PowerShell script in WinPE x64 and Windows x64 - how to script TS variables change?

    Question

  • Hi All,

    I have very simple VBS script for reading TS variables. It worked in SCCM 2007 with no issues. In SCCM 2012 script works only in WinPE and not in Task Sequence started from Software Center. Error is missing Microsoft.SMS.TSEnvironment. I tried everything with no luck.

    Script:
    Set objEnvironment = CreateObject("Microsoft.SMS.TSEnvironment")

    Foreach objVariablein objEnvironment.GetVariables
            strVariables = objVariable & " = " & objEnvironment(objVariable) & vbCrLf
    Next
    MsgBox strVariables

    Please Help.

    Thank you in advance.

    Regards,


    • Moved by Torsten [MVP]MVP Friday, April 05, 2013 8:41 AM moved to SDK subforum
    • Edited by AlwaysRealistic Tuesday, April 09, 2013 11:35 AM This is proper title...
    Thursday, April 04, 2013 3:37 PM

Answers

  • Hello,

    After many hours testing I finally have a solution!!! :-)

    Story for SCCM 2012 COMObject Microsoft.SMS.TSEnvironment is great if you use only x86 WinPE and x86 Windows.

    Things get ugly on x64 Windows/SCCM 2012 Client x64 with COMObject Microsoft.SMS.TSEnvironment.

    Note 1: TASK Sequence ALWAYS start the processes as 32BIT (for all SCCM 2012 Client and Windows ARCHITECTURE): PowerShell, CMD

    Note 2: on x64 Windows SCCM 2012 COMObject Microsoft.SMS.TSEnvironment works only with 64bit PROCESSES

    To Cut a Long Story Short:

    • TS + COMObject Microsoft.SMS.TSEnvironment + x64 Windows + PowerShell = %windir%\sysnative\WindowsPowerShell\v1.0\powershell.exe
    • If you want to combine both worlds x86 and x64 = create a Task in Task Sequence that will start PowerShell script that will start another PowerShell script in NATIVE ARCHITECTURE mode

    Regards,

    Thursday, July 11, 2013 1:44 PM

All replies

  • Hi Guys,

    [SCCM 2012 SP1]

    This is tested on several clean computers.

    No one answer so I want to update this topic with more details. (I hope that someone will help me)

    I have ~10 VB scripts that manipulate TS variables during OSD Task Sequence. VB script with code for manipulation of TS variables works normal SCCM 2012 WinPE 4.0 but same SCCM 2012 TS started in Windows from Service Center reports error. Error indicate line in VB script where Set objEnvironment = CreateObject("Microsoft.SMS.TSEnvironment") should execute.

    Microsoft.SMS.TSEnvironment is COMObject and I also tested with PowerShell with no success.

    I perform a test (when realize that normal way is not working) by starting commands in TS:

    ServiceUI.exe -process:tsprogressui.exe cmd /k powershell

    $TSenv = New-Object -COMObject Microsoft.SMS.TSEnvironment

    I started two command to prove that good(GREEN) and wrong (PURPLE) commands produce different output.

    I also tried to register problematic DLL but with no success:

    Please ... can someone show me how to further troubleshoot this problem or to inform me that there is a hotfix.

    Thank you in advance.

    Regards,

    Friday, April 05, 2013 7:59 AM
  • Hi Guys,

    Microsoft.SMS.TSEnvironment COMObject is not working on x64 OS but it WORKS on x86 OS.

    X86:

    X64:

    I still hope for HELP. 

    Regards,


    Monday, April 08, 2013 12:48 PM
  • On the 64-bit OS, are you calling that COM object from a 32-bit process?

    If you're continuing to have issues it may be worthwhile to leave a Connect feedback or contact support.

    Tuesday, April 09, 2013 6:22 PM
  • Hi Adam,

    I posted feedback on Microsoft Connect as you proposed.

    I tried to access Microsoft.SMS.TSEnvironment COMObject from Task Sequence with x86 processes on Windows 7 SP1 x64:

    ServiceUI.exe -process:tsprogressui.exe %SystemRoot%"\SysWOW64\cmd.exe /k %SystemRoot%"\SysWOW64\powershell.exe
    

    and then manually type:

    $TSenv = New-Object -COMObject Microsoft.SMS.TSEnvironment

    with no success.

    I also look into registry for class Microsoft.SMS.TSEnvironment and compare with recommendation for x86 COMObjects on x64 Windows and I did not see any problem there.

    Regards,

    Wednesday, April 10, 2013 8:05 AM
  • Hi All,

    I reported this issue on Microsoft Connect and no update so far.

    Problem is REALLY easy to reproduce. Just start "WinPE 4.0 x64" and start this in PowerShell:

    $TSenv = New-Object -COMObject Microsoft.SMS.TSEnvironment

    Can someone confirm that it is working on WinPE 4.0 x64 or Windows 7 SP1 x64?

    Please help.

    Regards,

    Wednesday, May 22, 2013 8:45 AM
  • Yes, working for me, doing it all the time, like here: http://www.david-obrien.net/2012/10/13/easy-versioning-of-imagesconfiguration-manager-and-powershell/
    That blog was still pre-SP1 (so, no WinPE4), but I did the same just before my vacation and all is fine.


    David O'Brien | MCITP/MCSE/MCSA, CCEE/CCIA | My blog: www.david-obrien.net | me on Twitter: @david_obrien | sepago GmbH

    Wednesday, May 22, 2013 8:28 PM
  • I'm having the same issues.

    I use SCCM 2012 SP1 with a 32bit pe image while deploying 64bit windows.
    When I start the script from a console within the PE environment it sometimes works but most of the time it doesn't.
    If I launch the script from the TS it never works.

    It seems in my case the clsid is all zero's.

    I solved it by creating a script with a parameter. My commandline:

    powershell -setexecutionpolicy bypass;powershell z:\backup.ps1 %_SMSTSMachineName%

    Friday, June 07, 2013 8:55 AM
  • Hello,

    After many hours testing I finally have a solution!!! :-)

    Story for SCCM 2012 COMObject Microsoft.SMS.TSEnvironment is great if you use only x86 WinPE and x86 Windows.

    Things get ugly on x64 Windows/SCCM 2012 Client x64 with COMObject Microsoft.SMS.TSEnvironment.

    Note 1: TASK Sequence ALWAYS start the processes as 32BIT (for all SCCM 2012 Client and Windows ARCHITECTURE): PowerShell, CMD

    Note 2: on x64 Windows SCCM 2012 COMObject Microsoft.SMS.TSEnvironment works only with 64bit PROCESSES

    To Cut a Long Story Short:

    • TS + COMObject Microsoft.SMS.TSEnvironment + x64 Windows + PowerShell = %windir%\sysnative\WindowsPowerShell\v1.0\powershell.exe
    • If you want to combine both worlds x86 and x64 = create a Task in Task Sequence that will start PowerShell script that will start another PowerShell script in NATIVE ARCHITECTURE mode

    Regards,

    Thursday, July 11, 2013 1:44 PM
  • Hi,

    I'm actually experiencing this same issue in WinPE 5.0 x64.  There is actually no 32-Bit cscript.exe, cmd.exe or powershell.exe in the X:\Windows\SysWOW64 folder nor is there a Sysnative redirect.  Can someone from Microsoft comment on this?  I am unable to access the Microsoft.SMS.TSEnvironment COM Object from WinPE 5.0 x64 using the OSD Prestart commands.

    It works after executing a Task Sequence (somehow), but not before.

    Wednesday, February 05, 2014 2:06 AM