Add PC to Collection During Task Sequence

I would like to automatically add an Unknown PC to a specific collection during a task sequence.  I came across a VBScript that does this on the following site:

http://blogs.msdn.com/b/vinpa/archive/2010/09/01/how-to-add-a-known-unknown-computer-to-a-specified-collection-during-os-deployment.aspx

According to the explanation you run the script as a 'Run Command Line' task in the Task Sequence specifying the following Command line:

cscript AddMeToCollection.vbs sccmservername collectionID %_SMSTSClientIdentity%

I run this script with an account that has full admin rights on the SCCM Server.  It is my understanding that you can not use a command line step that uses a specific account during the Windows PE phase, therefore I run this task after a reboot that restarts the PC with the installed Operating System.  This task is run after the Setup Windows and ConfigMgr step.

Although the task completes successfully with a 0 exit code, the PC does not get added to the specified collection.  Looking at the logs the output of the script is as below:


===================================
   ADDING COMPUTER TO COLLECTION
===================================
Site Server specified: mysccmserver
Collection ID specified: SMSxxxxxx
SMS Client GUID:xxxxx
Computer Name: myPC
SMS Provider Namespace = \\mysccmserver\root\sms\site_XXX
Successfully Connected to the SMS Provider Namespace.

Looking at the script it seems if the script were to execute successfully some further messages would be output:

WScript.Echo "Resource ID = " & strResourceID


WScript.Echo strComputerName & " successfully added To " & strCollID

Has anyone successfully used this script or a similar script to add a PC to a specific collection during the Task Sequence?  Any advice as to where I may be going wrong would be greatly appreciated.  I am using SCCM 2007 R3 and deploying Windows 7 Enterprise 64 Bit.
April 19th, 2013 12:53am

It is not recommended that you use domain admin to run the command. You can use a regular domain account. Notice that you need to allow the account to manage the SMS provider in site database.

1.From the Start menu, click Run and type Dcomcnfg.exe.

2.In Component Services, click Console root, expand Component Services, expand Computers, and then click My Computer. On the Action menu, click Properties.

3.In the My Computer Properties dialog box, on the COM Security tab, in the Launch and Activation Permissions section, click Edit Limits.

4.In the Launch Permissions dialog box, click Add.

5.In the Select User, Computers, or Groups dialog box, in the Enter the object names to select (examples): box, type SMS Admins and click OK.

6.In the Permissions for SMS Admins section, select the check box to allow Remote Activation.

7.Click OK twice, and then close Computer Management.

Free Windows Admin Tool Kit Click here and download it now
April 23rd, 2013 9:13am

Arthur-Thanks for the input. I checked your suggestion and the account I am using already had those permissions assigned in Dcomcnfg.  The script still fails saying it could not find the resource id for the computer.

 

Anyway I managed to find a work around, but once again thanks for the suggestion.


April 30th, 2013 11:03am

To me it seems like the issue could be that since the machine is unknown at the time it will not have a resource ID until Win 7 is installed and the configmgr client is installed and setup. I noticed you mentioned that you placed this script after the ConfigMgr & Windows Setup task, however it's possible that your PC hasn't updated the SCCM database with the new record that fast and thereforth it's still null.  Maybe try moving this script further down in the task sequence and see if that helps. If you want to do a quick test, use a machine that already has an active resource ID and just reimage it.
Free Windows Admin Tool Kit Click here and download it now
May 3rd, 2013 6:55pm

What was the work around that you found?  I am wanting to do this same thing in SCCM 2012.

I tried the same script and also placed it in various positions thru out the task sequence and had no luck either.

Thanks

March 14th, 2015 1:02am

I too am having no luck. Windows is installed, I'm still within the task sequence but i receive the error "could not find the resource id for the computer"
Free Windows Admin Tool Kit Click here and download it now
April 9th, 2015 8:51am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics