March 12 2010

Remove computer association from collection after SCCM task sequence

During SCCM OS deployment, you need to add a computer association so you can deploy your OS to a targeted machine. The problem with this is that the computer resource is still left in the collection after deployment. Use this technique to delete the resource once a successful OS deployment is completed:

Copy the below code into a VBS file called remove_from_collection.vbs.

Modify the code so that the sCollectionID = “ABC00013” has the collection ID of your collection from which the resource will be deleted:


On Error Resume Next
Dim oNetwork, oLocator, oSWbemServices, oCollection
Dim sComputerName, sSMSServer, sSMSSiteCode, sCollectionID, RuleSet
Set oNetwork = CreateObject("WScript.NetWork")
'CollectionID from which to remove the comouter
sCollectionID = "ABC00013"
'————————————————————
'Get Command Line arguments
Set args = WScript.Arguments
sComputername = args.Item(0)
If sComputerName = NULL then
wscript.quit
End if
'————————————————————
'Main script
Set swbemLocator = CreateObject("WbemScripting.SWbemLocator")
swbemLocator.Security_.AuthenticationLevel = 6 'Packet Privacy.
Set swbemServices = swbemLocator.ConnectServer(".", "rootSMS")
Set oProviderLocation = swbemServices.InstancesOf("SMS_ProviderLocation")
For Each oLocation In oProviderLocation
If oLocation.ProviderForLocalSite = True Then
Set swbemServices = swbemLocator.ConnectServer(oLocation.Machine, "rootsmssite_" + oLocation.SiteCode)
End If
Next
Set oCollection = SWbemServices.Get("SMS_Collection='" & sCollectionID & "'")
RuleSet = oCollection.CollectionRules
For Each Rule In RuleSet
If Rule.Path_.Class = "SMS_CollectionRuleDirect" Then
If LCase(Trim(Rule.RuleName)) = LCase(Trim(sComputerName)) Then
oCollection.DeleteMembershipRule Rule
End If
End If
Next
WScript.Quit(0)

Create a Status Filter rule by going to Site Database – Site Management – Primary Site – Site Settings – Status Filter Rules.

On the general tab, use Component : Task Sequence Manager, Message ID: 11171 .

On the actions tab, tick Run a program and use something like ‘cscript.exe D:SCRIPTSremove_from_collection.vbs %msgsys’.


This will trigger the script each time a task sequence is reported to the SCCM primary site to be completed successfully and will use the computername (%msgsys) from the status message and remove it from the collection in the script.

Original posting and more discussion here –> http://social.technet.microsoft.com/Forums/en-US/configmgrsdk/thread/9205e49b-9d0e-462e-8998-87e6c31f9c41

Further samples and additional parameter information can be found here http://technet.microsoft.com/en-us/library/bb693758.aspx and http://technet.microsoft.com/en-us/library/cc181183.aspx



----------------------------------------------------------------------------
I use a maximum of one Google Ad per post to help offset some of my blog hosting costs.

----------------------------------------------------------------------------

March 11 2010

SCCM task sequence log file locations

The first step to troubleshoot SCCM OSD Task Sequence issues to is check out the log file – this is called smsts.log.

This can be found in one of several locations depending on the progress of the build and the architecture of the OS:

  • Windows PE before HDD format: x:windowstempsmstslogsmsts.log
  • Windows PE after HDD format: x:smstslogsmsts.log and copied to c:_SMSTaskSequenceLogsSmstslogsmsts.log
  • Full version Windows before SCCM agent installed: c:_SMSTaskSequenceLogsSmstslogsmsts.log
  • Full version Windows after SCCM agent installed: c:windowssystem32ccmlogsSmstslogsmsts.log
  • Full version Windows (x64) after SCCM agent installed: c:windowssysWOW64ccmlogsSmstslogsmsts.log
  • After Task Sequence has finished running: c:windowssystem32ccmlogssmsts.log
  • After Task Sequence has finished running (x64): c:windowssysWOW64ccmlogssmsts.log

Of course, don’t even bother trying to open these with notpead, make sure you use the Trace32 tool found in the ConfigMgr 2007 Toolkit.

Whilst we are talking about SCCM logs, there is a great article here (http://blogs.msdn.com/lxchen/archive/2009/04/03/a-list-of-sccm-log-files.aspx) outlining a list of all SCCM log files.

March 10 2010

SCCM Resource Explorer

It’s often quite a painful experience to open up resource explorer in SCCM. I’ve modified a batch file (originally from http://www.windows-noob.com/forums/index.php?/topic/687-resource-explorer-shortcut-for-sccm-2007/) to make this process very simple. Create a new batch file with the following content, it will then prompt you for all of the required parameters:

@echo off
CLS

> input1.vbs ECHO WScript.Echo InputBox( "Which SCCM client would you like to connect to?", "Resource Explorer", "Enter client name" )
FOR /F "tokens=*" %%A IN ('CSCRIPT.EXE //NoLogo input1.vbs') DO SET clientname=%%A
DEL input1.vbs

> input2.vbs ECHO WScript.Echo InputBox( "What is the SCCM server name?", "Resource Explorer", "Enter server name" )
FOR /F "tokens=*" %%A IN ('CSCRIPT.EXE //NoLogo input2.vbs') DO SET servername=%%A
DEL input2.vbs

> input3.vbs ECHO WScript.Echo InputBox( "What is the SCCM site code?", "Resource Explorer", "Enter site code" )
FOR /F "tokens=*" %%A IN ('CSCRIPT.EXE //NoLogo input3.vbs') DO SET sitecode=%%A
DEL input3.vbs

c:
cd
cd "Program Files (x86)Microsoft Configuration ManagerAdminUIbin"

start resourceexplorer.msc -s -sms:ResExplrQuery="SELECT ResourceID FROM SMS_R_SYSTEM WHERE NAME = '%clientname%'" -sms:connection=\%servername%rootsmssite_%sitecode%