How to: Use 1E Shopping to provision a System Center Configuration Manager Maintenance Window

Overview

1E has customers which have asked about utilizing Shopping in order to provision a ConfigMgr Maintenance Window. This document will discuss one method whereby 1E Shopping can be used to provision a ConfigMgr Maintenance Windows by leveraging the new Workflow Integration feature of Shopping 3.2 and Discovery Data Records as discussed in the Configuration Manager 2007 SDK.

The overall concept is to utilize the Shopping THIRDPARTYAPPREF field that is available on all 1E Shopping Applications to generate a DDR record in ConfigMgr. The THIRDPARTYAPPREF value is designed as a unique reference for interfacing with other third party tools. When a user shops for an application 1E Shopping can be configured to initiate a workflow (aka script) which is called on completion of various events. In this scenario the script is configured to assign a specific attribute for example:“MW1-00001” to each client within ConfigMgr. Shopping is able to perform this task because shopping knows the relevant details (SMSGUID,SITE,NAME) of each client computer within the ConfigMgr server due to the ActiveX control (Shopping Probe) where the client computer is assigned therefore we can re-use this information as an automation method to create a DDR record. The result is an attribute assignment that can be utilized as a basis for collection memberships within ConfigMgr 2007 infrastructure and is completely independent of the existing Shopping managed collections or advertisements.

In addition standard shopping authorization and access and approval models apply which is to say that end-users and administrators will to have access to these Maintenance Windows packages as defined by normal shopping computer categories or user categories or by approvals if desired.

Customer Requirements

These are the requirements which were stated around the self-service shopping for Maintenance Windows.

  • 1E Shopping must be able to assign a value to computers within ConfigMgr 2007.
    • This value will allow the any maintenance window collections to be defined as query based rather than direct membership collections which is the 1E shopping method for managing collections.
  • Must be able to utilize shopping in its normal capacity to shop for applications. i.e if the THIRDPARTYAPPREF does not contain a MW then normal shopping rules apply and direct membership rules will be used.
  • The end-user can only shop for Maintenance windows after X days from last Maintenance Window request via shopping. Although this method is not implemented in the sample script included in this document. This can be achieved by simply writing the DDR files to a local folder on the shopping server and checking the date/time stamp on the file with the current date of the request.
    • If the user requests a new maintenance window with X days then the request will automatically fail and the user will receive a message notifying them that the request failed due to this constraint.
  • Must be able to shop for MW’s for other computers, based on access rights.

Software Requirements

This solution has the following requirements.

  • Windows Server 2003 or greater. (Windows Server 2008 R2 Preferred)
  • IIS 7.0 and above with Windows Authorization and ASP.NET enabled
  • 1E Shopping 3.2 and the current hotfixes and/or rollups
  • ConfigMgr 2007 SP2 or later
  • ConfigMgr 2007 SDK

Implementation

In order to implement this solution you must have the following components installed.

  • 1E Shopping v3.2
    • Shopping Workflow enabled
  • Microsoft System Center Configuration Manager

How to register the SMSRSGENCTRL.DLL

The ConfigMgr 2007 SDK is required in order to generate a DDR for client computers within ConfigMgr 2007. This is process to register the dll named above.

  • Install the Microsoft System Center ConfigMgr 2007 SDK onto a Primary site
  • Copy the smsrsgenctrl.dll and the smsrsgen.dll from C:\Program Files (x86)\Microsoft System Center Configuration Manager 2007 SDK\Redistributables folder to a folder located on the Shopping Central server. This example uses a folder called “utils”
  • Open a command prompt and switch to the utils folder
  • Run the command regsvr32 smsresgenctrl.dll, which should yield the following.

Creating a Shopping Application

The following is an example of how to create a shopping application for end-users to provision a Maintenance Window of their choice. This example will be used in the subsequent section to build a collection in ConfigMgr.

  • Open the Shopping Administration Console
  • Navigate to the Applications Node
  • Create a new non-SMS/ConfigMgr application with the properties below

*Note* The key element above is the Application Ref: “MW1-D0001”

Defining a ConfigMgr Collection

These are the properties that control the computer systems that are members of this specific Maintenance Window collection.

ApprovalProcessCompleted.vbs Sample script

The script below would replace the default ApprovalProcessCompleted.vbs script in Shopping.

'this script was written as a demo to provision Maintenance Window in ConfigMgr' using 1E Shopping
'Author: Richard Fellows @ 1E
'
'------------------------------------------------------
' version 1
'------------------------------------------------------
Const ADDPROP_NONE = &H0
Const ADDPROP_FULLREPLACE = &H1
Const ADDPROP_GUID = &H2
Const ADDPROP_KEY = &H8
Const ADDPROP_NAME = &H44

Dim strConfigMgrServer, strMW
Dim DDR, strComputer, strSiteCode, strGUID
Dim Logfile, objFS, intLogsize, strLogfile, strScriptName, oFile, strOldLogFile strSiteCode = "%SITE%"
'lookup to copy DDR to the correct site Server based on client assigned site if strSiteCode = "CFM" then strConfigMgrServer = "OHWANCFM4401"

'------------------------------------------------------
'variables replaced by the ShoppingCentral service account prior to execution of the script.
'------------------------------------------------------

strComputer = "%MACHINENAME%"
strMW = "%THIRDPARTYAPPREF%"
strGUID = "%GUID%"

if Len(strMW)<>9 Then Wscript.quit 'if the length of THIRDPARTYAPPREF is NOT 9 skip it
if UCase(Left(strMW,2)) <> “MW” then Wscript.quit 'if the THIRDPARTYAPPREF does not begin with “MW” then skip it

'-------------------------------------------
' create an object for generating SMS DDR's
'-------------------------------------------

Set DDR = CreateObject("SMSResGen.SMSResGen.1")

GenerateDDR strComputer,strConfigMgrServer,strSiteCode,strMW,strGUID

'------------------------------------------------------
' this is the function that does the DDR generation and copies it to the ConfigMgr Site Server
'------------------------------------------------------

Function GenerateDDR(strComputer,strConfigMgrServer,strSiteCode,strMW,strGUID) 
'Build the DDR
DDR.DDRNew "System", "Maintentance Window", strSiteCode
DDR.DDRAddString "Name", strComputer, 25, ADDPROP_NAME
DDR.DDRAddString "Maintenance Window", strMW, 9, ADDPROP_NONE
DDR.DDRAddString "SMS Unique Identifier", strGUID, 64, ADDPROP_GUID And ADDPROP_KEY

'Now write the DDR to the site server
' *note* in this next line of code files can be written locally to a folder on the shopping server as well for backup purposes.
'DDR.DDRWrite "C:\" & strSiteCode & "_" & strComputer & ".ddr"
DDR.DDRWrite "\\" & strConfigMgrServer & "\SMS_" & strSiteCode & "\inboxes\auth\ddm.box\" & strSiteCode & "_" & strComputer & ".ddr"
' *Note* it would be nice if we could monitor ConfigMgr to a status message when the DDR is 'processed as well
' ---maybe for a future release? ---
' Additional work: Customer may want to implement a restriction on how often the customer 'can shop for a Maintenance Window example if the last DDR was created less the xx days ago. 'Discard the request and notify the customer via email
End Function

Share this post

Share this post on your favourite social media platform.

Find this article useful?

If so please click here