Tuesday, March 25, 2014

Microsoft SCCM 2012: Creating a file copy Task Sequence

If you need to copy a set of files to a location on a workstation you can accomplish this by setting up a package containing your source files, then setting up a Run Command Line Task sequence to copy the contents of your package to the location you want the files to reside on your system.

The first step is to create a source only (non-program) package with the following steps
  1. Go to Software Library, Application Management, Packages, and select Create Package.
  2. Provide a Name for your package (Description, Manufacturer, Language, and Version are optional).
  3. Place a check in "This package contains source files".
  4. Browse to your source files folder and click ok when finished.
  5. Click Next.
  6. Select the option "Do not create a program"
  7. Click Next, Next, Close.
  8. Select your new package and be sure to Distribute Content to your distribution point(s).
Next we will create a Task Sequence to copy the contents of the package to a destination on the endpoint.  This process will utilize the Run Command Line task as well as a method where you can place multiple commands into one command line as reference in the previous post.

  1. Go to Software Library, Operating Systems, Task Sequences.  Here we can create a new task sequence or edit an existing task sequence and make the following changes.
  2. In the task sequence select Add, General, Run Command Line.
  3. Provide a name for your Run Command Line task.
  4. In the command line you will perform a command similar to the following to make a directory if it doesn't exist and then perform then copy the files (if the directory already exists no make directory is needed).
    1. cmd.exe /c md C:\Windows\Temp\FileCopyExample & cmd.exe /c xcopy ".\*" C:\Windows\Temp\FileCopyExample /y /e
  5. Place a check in Package, then browse to the package you created in the first step.
  6. Click Ok to save and close the task sequence

The Task sequence can now be deployed to collections where it is needed.

Monday, March 24, 2014

Microsoft SCCM 2012: Running multiple commands from a Run Command Line Task Sequence

In SCCM 2012 Task Sequences there is an option to Run Command Line as shown in the following picture:


This is generally used when a command needs to be run during the post Setup Operating System area of a Task Sequence.  In most of the examples I have seen people have created a separate Run Command Line task for each command they want to execute.  This will work, but I wanted to clean things up a bit and thought there must be a way to perform more than one command in a command line.

This is where the & operator comes in.  When you used the & operator of the cmd.exe command you can add multiple commands to the same line.  Following is an example of how to configure your Run Command Line to perform multiple commands in one Run Command Line.


In general the format is as follows:
cmd.exe /c somecommand1 & cmd.exe /c somecommand2 & cmd.exe /c somecommand3 & etc...

I will have other followup posts in the near future with examples of this method.  If you have other tips and tricks with the Run Command Line please feel free to post them in the comments.