Accessing Task Sequence Variables within a Powershell Script during the TS

***UPDATE 13-Oct-2014 – My post here may be relevant to you ***

This information came from here, and I am duplicating it in part on the off-chance that the originating site is down as well as being a handy reference for myself.  I recommend that you visit the site for full details as you may encounter a couple of “Gotcha’s” that I have not duplicated here.

The Task sequence environment variables are easily accessible through the Microsoft.SMS.TSEnvironment ComObject .

To use this com object simply use the following line in your powershell script.

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

You can then easily access any existing variable using the following syntax :


Using this line will retrieve the current logging path.

Be the first to comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.