How to retrieve SCCM 2007, Task Sequence Collection Variables' Name and Value with Powersehll


  • Hi,

    I am trying to get the  Value from SCCM2007, Collection variables VALUE from Task Sequence variable and not getting the value.

    following the instruction by Michael Neihauswith's article

    But i am getting empty value.

    $tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment
    $member = $tsenv | get-member
    $tsenv.Value("ZTIRoleID") = "ZTIRoleID"
    $ZTIRole = $tsenv.Value("ZTIRoleID")
    (get-date).ToString() + "Value of tsenv   is $tsenv" | Add-Content c:\windows\temp\Variable_Value.log
    (get-date).ToString() + "Value of member   is $member" | Add-Content c:\windows\temp\Variable_Value.log
    (get-date).ToString() + "Value of ZTIRole is $ZTIRole" | Add-Content c:\windows\temp\Variable_Value.log

    the logs read...

    -Value of tsenv   is System.__ComObject

    -Value of memeber   is void Clear () void Create () Variant GetVariables () string Value (string) {get} {set} 

    -Value of ZTIRole is                           ####just said, Value of ZTIRole is and no Value

    what am i missing?


    Sunday, September 29, 2013 7:04 PM

All replies

  • Are you running this within a task sequence?

    Jason |

    Sunday, September 29, 2013 7:45 PM
  • Hi Jason,

    Thank you for your response. Yes, I am running from TS. I know the script run inside TS. I am not sure its durable to get the collection variable value? In case if I describe incorrectly, this is what i means.

    Configuration Manager Console

    Right click on collection --> Modify Collection Settings --> Collection Variables Tab --> Variables Name "ZTIRoleID", Value is 01.

    I try to get the value "01".

    Hope this will help.

    Monday, September 30, 2013 2:26 AM
  • Just a quick one - is the task sequence assigned to the collection that has the variable? 

    If not -  it's not going to be able to retrieve this variable.

    Thursday, October 03, 2013 2:06 AM
  • Trun out that AD Domain admin Account can't retrive the TS Environment value. which i tried.  "Run this step as the following accunt".

    thanks you guys

    Friday, October 11, 2013 2:31 AM