Wednesday 24 December 2008

RunAs in SCCM 2007 R2

When deploying an OS using a Task Sequence, you might need to run a step as a particular user. By default OSD runs all application installs under the localsystem account, but some applications don't behave as expected under this context. For example, the package SPSS requires the use of a program called spssactivator.exe to license the product and this only seems to work if run as Administrator.

In the example of SPSS, the following command line needs to be run from C:\Program Files\SPSS as the local administrator-

spssactivator productkey

This is where SCCM 2007 R2 comes in handy. The Run Command Line step has a new option Run this step as the following account. Clicking the Set button allows the credentials of the account to be set. But there is a problem. Credentials can be set in either of these two formats-

domain\user

or

%variable%

-but annoyingly, this format is not supported-

%OSDComputername%\user

So how can the Task Sequence be told to run the command as the local administrator? Well, it's quite simple - just set the %OSDComputername%\Administrator up as a variable in a separate step before the Run Command Line step.

So, add another step to the Task Sequence of Set Task Sequence Variable. Set the variable name to something memorable, such as RUNASACCOUNTFORSPSS, and set the variable value to %OSDComputername%\Administrator.



In the Run Command Line step, enter %RUNASACCOUNTFORSPSS% as the account to use, and supply the password.



You can then deploy the task sequence to any number of machines and the command line will use the correct credentials. Obviously you need to ensure the local account exists, is enabled, and you have supplied the correct password.

No comments: