Using the CustomSettings.ini file, MDT DB, Configuration Manager 2007 R3 collection variables, or Configuration Manager 2007 R3 computer variables, you can specify a list of Configuration Manager packages for installation on the target computer.

Adding the Install Software task sequence step to a Configuration Manager 2007 R3 task sequence initiates the installation of Configuration Manager packages. However, as a security precaution, Configuration Manager 2007 R3 does not default to allow programs to run via task sequences. The task sequence will fail unless you select the program’s Allow this program to be installed from the Install Software task sequence without being advertised check box.

The sample script in Listing 22 enumerates each Configuration Manager 2007 R3 program, checking to see if the first bit (AUTHORIZED_DYNAMIC_INSTALL, described briefly in the Configuration Manager 2007 R3 software development kit) of the ProgramFlags field is enabled. If not, the script enables it. In most cases, run this script (using credentials with sufficient rights) on any Configuration Manager 2007 R3 site server on which packages are configured and need to be available for installation via task sequences.

The script contains basic logic to detect failures that might be caused by the user’s not having the required rights to perform the configuration change or failures where the package being modified isn’t owned by the specified site (for example, the script is running on a lower-level primary site that received packages/programs from its parent site).

Prior to running this script, customize it to match the Configuration Manager 2007 R3 environment. For example, set the sSiteCode variable to the correct Configuration Manager 2007 R3 site code. Also, if running this script against a remote Configuration Manager site server, set the sProviderServer variable to specify the correct Configuration Manager site server name and, optionally, the sUsername and sPassword variables to specify alternate user credentials for the remote connection.

Note   Do not configure sUserName or sPassword variables when running the script while logged on to the Configuration Manager site server.

Note   You can modify the script to enable only specific programs or to exclude specific programs from being enabled.

This script should be run from a Command Prompt window using the command line cscript.exe EnableProgramForTS.vbs.

Listing 22. Example script to enable the Allow this program to be installed from the Install Software task sequence without being advertised check box for all Configuration Manager 2007 R3 programs

' //*******************************************************

' // ***** Script Header *****

' //

' // Solution:  Microsoft Deployment Toolkit

' // File:      EnableProgramsForTS.vbs

' //

' // Purpose:   Enable the "Allow this program to be

' //            installed from the Install Software

' //            task sequence without being advertised"

' //            check box for all ConfigMgr programs.

' //

' // Usage:     cscript.exe EnableProgramsForTS.vbs

' //

' // Microsoft Solution Version:  4.2.662

' // Microsoft Script Version:    4.2.662

' // Customer Build Version:      1.0.0

' // Customer Script Version:     1.0.0

' //

' // Microsoft History:

' // 4.2.662 MTN  05/09/2008  Created initial version.

' //

' // Customer History:

' //

' // ***** End Header *****

' //*********************************************************

 

'//--------------------------------------------------------

'//

'//  Set global variables, used by the ZTIProcess

'//  function below. 

'//

'//  If ConfigMgr is running on the same server, the

'//  sProviderServer value can be left blank and

'//  the sUsername and sPassword values must be

'//  blank.

'//--------------------------------------------------------

 

Option Explicit

 

Dim sProviderServer

Dim sSiteCode

Dim sNamespace

Dim sUsername

Dim sPassword

 

sProviderServer = ""

sSiteCode = "CEN"

sNamespace = "root\sms\site_" & sSiteCode

sUsername = ""

sPassword = ""

 

'//--------------------------------------------------------

'//  Main routine

'//--------------------------------------------------------

 

ZTIProcess

 

Function ZTIProcess

 

  Dim oLocator

  Dim oSMS

  Dim sQuery

  Dim oPrograms

  Dim oProgram

  Dim iCount

  Dim sErr

 

  ' Connect to the SMS provider

 

  Set oLocator = CreateObject("WbemScripting.SWbemLocator")

  Set oSMS = oLocator.ConnectServer(sProviderServer, _

                                    sNamespace, _

                                    sUsername, _

                                    sPassword)

 

  ' Build the query

 

  sQuery = "SELECT * FROM SMS_Program"

 

  ' Process the query

 

  iCount = 0

  Set oPrograms = oSMS.ExecQuery(sQuery)

  For Each oProgram in oPrograms

 

    If (oProgram.ProgramFlags And 1) = 0 Then

      oProgram.ProgramFlags = oProgram.ProgramFlags Or 1

      WScript.Echo "Enabling: " & oProgram.PackageID & _

                   ":" & oProgram.ProgramName

      On Error Resume Next

      oProgram.Put_

      If Err Then

        sErr = "ERROR enabling " & oProgram.PackageID & _

               ":" & oProgram.ProgramName & " " & _

               "possibly because of insufficient " & _

               "rights or because the package is not " & _

               "owned by this site. " & Err.Description

        WScript.Echo sErr

      Else

        iCount = iCount + 1

      End If

    End If

 

  Next

 

  WScript.Echo "Total programs enabled: " & iCount

 

End Function


Related Topics

Microsoft Deployment Toolkit Samples Guide