In order to get these identification items into SCCM available for selection based on a (SQL) query, collection variables can be used to identify a machine as part of client xyz. the mechanism to enable this is drawn in the following figure:
It works as follows:
- Define collection variables on the collection in SCCM which holds all object you want this variables to hold (this link shows how)
- Modify the MOF files used for hardware discovery (see link)
- Create a package that holds a script that reads the collection variables and sets them in the registry of the client (an example is shown here, we use the registry key Workspace as means of selection of these kind of variables) . Deploy the package to the collection mentioned in step 1
#############################
#
# ToolingVariables.ps1
# Script designed by Bas Huygen
# jan 2014
# version 0.3
#############################
If(Test-Path -path HKLM:\Software\Workspace){
$tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment
#set definitions
$Customer = $tsenv.Value("Customer")
$CustomerEnvironment=$tsenv.Value("CustomerEnvironment")
$Customercode=$tsenv.Value("Customercode")
$SLA=$tsenv.Value("SLA")
$WorkspaceName=$tsenv.Value("WorkspaceName")
$WorkspaceVersion=$tsenv.Value("WorkspaceVersion")
$ToolingVar1=$tsenv.Value("ToolingVar1")
$ToolingVar2=$tsenv.Value("ToolingVar2")
$ToolingVar3=$tsenv.Value("ToolingVar3")
#set registry items
set-itemproperty -path HKLM:\Software\Workspace -name Customer -value $Customer
set-itemproperty -path HKLM:\Software\Workspace -name CustomerEnvironment -Value $CustomerEnvironment
set-itemproperty -path HKLM:\Software\Workspace -name Customercode -Value $Customercode
set-itemproperty -path HKLM:\Software\Workspace -name SLA -Value $SLA
set-itemproperty -path HKLM:\Software\Workspace -name WorkspaceName -Value $WorkspaceName
set-itemproperty -path HKLM:\Software\Workspace -name WorkspaceVersion -Value $WorkspaceVersion
set-itemproperty -path HKLM:\Software\Workspace -name ToolingVar1 -Value $ToolingVar1
set-itemproperty -path HKLM:\Software\Workspace -name ToolingVar2 -Value $ToolingVar2
set-itemproperty -path HKLM:\Software\Workspace -name ToolingVar3 -Value $ToolingVar3
}
Else{Write-Warning "This system is already equipped with customer variables; Installation aborted"}
- Create a Task Sequence that reads the collection variables and registers them in the local registry with the aid of the script of step 3
-
Read the collection variables like thisUse the script like this
- Deploy this task sequence to the collection of the machines you want to configure with collection variables
- The variables are set in the registry of the client by running the script from step 3
- The next hardware scan the relevant portion of the registry is scanned and the results are added to the hardware properties of the client in the SCCM database
As soon as the registry has the settings and the MOF file is modified to scan the relevant portion of the registry, these settings are available in SCCM for querying. now you can create collections based on these settings and build reports with it as well.
Example of query criterion in SCCM 2012 R2