Using PowerShell to set OSD task sequence variables

For a few months now I have been trying to work out running a simple PowerShell script to set some task sequence variables in my build and capture task sequence. This is easily doable with a package/application and a wrapper but I wanted a one liner that could be ran from a run command line task. Easy to implement, and even easier to use, because you don’t have to worry about source updates or any files whatsoever.

I finally got it working this weekend! Long story short it ended up being two things:

  • When calling a PowerShell command using powershell.exe and the -command parameter you must specify “& { your command here }”
  • When setting a task sequence variable via PowerShell, you must use single-quotes, not double quotes.

Previously I was using the following command, and it did not work.

I caught another example someone had posted on a forum reply on technet and they had made the two changes I noted above. The command now looks like this:


This is exactly what I was looking for. I am using the %ImageVersion% variable to do two things.

  • Brand the image version to the registry
  • Brand the image version to the captured .wim



I found it pretty amazing that the task sequence variable worked on the Capture task. This brings me one step closer to a fully automated image build.

3 thoughts on “Using PowerShell to set OSD task sequence variables

  1. […] or PowerShell can do a lot of the work for you if the information you need is on the machine you are deploying. […]

  2. LvilleSystemsJockey

    Worked like a champ.

Leave a Reply to Daniel Ratliff Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url=""> 

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