Showing posts with label System Center Config Manager 2012. Show all posts
Showing posts with label System Center Config Manager 2012. Show all posts

Friday, January 24, 2014

Use SCCM Collection variables to target Client computer objects

When you decide to use SCCM 2012 as a configuration manager for multiple tenants (comprising of multiple clients) SCCM does not have means to select computer object of a specific client on its name and subsequently its environment, SLA etc. to enable this mechanism SCCM must have a means of identification to make a query.
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:
image
It works as follows:
  1. Define collection variables on the collection in SCCM which holds all object you want this variables to hold (this link shows how)
  2. Modify the MOF files used for hardware discovery (see link)
  3. 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"}
  4. 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
  5. Read the collection variables like this
    Use the script like this
  6. Deploy this task sequence to the collection of the machines you want to configure with collection variables
  7. The variables are set in the registry of the client by running the script from step 3 
  8. 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
image
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.
image
Example of query criterion in SCCM 2012 R2

Wednesday, November 13, 2013

Reinstall SCCM 2012 CAS server

This week i have been busy installing System Center Config Manager 2012 SP1 on a big new delivery site my company is building.

Long story short, installing SCCM 2012 in a new environment is not that difficult BUT when you experience an entire system down during an upgrade of config manager 2012 from SP1 to R2, the recovery of such a Hierarchy is some challenge.
this is the situation: (i use CM12 as a short for System Center Config Manager 2012)

  • CM12 CAS based on SP1 named CasServer installed with CM12 SP1 CU3
  • CM12 Primary site as child of the previous CAS installed with CM12 SP1 CU3
  • The CAS has a separate (physical) SQL server 2012 with a name like SQLServer
  • The Primary has SQL 2012 installed locally as its own Database server named PriServer
sccmsitecas-pri

 
  • The CAS was in the middle of the upgrade of CM12 SP1 to R2
The Entire Cluster went down at that moment the setup was configuring the CAS database. After the recovery of the cluster my CM12 configuration was just hopeless. none of the consoles worked and services were complaining about anything.

I tried the following recovery scenarios:
  • Restore of the CAS DB on SQLServer: SUCCESS
  • Recovery of the CAS with the option: "recover site from manually restored database" : SUCCESS
  • Check of full functionality in CM12 manager: FAIL - Database replication from CAS to PRI failed with error message:
  • Next scenario: Upgrade CAS to CM12 R2: FAIL replication will not start because of inconsistent content in the queue of the Primary site server
  • Next scenario: Uninstall PRI and CAS and reinstall CAS, recover old CAS DB and restart CM12: SUCCES though it has some hooks that i will explain here.
How to recover a CAS while the current CAS DB is in unknown state:
  • Have a good CAS Database backup ready and online to use
  • Uninstall All connected primary sites from the CAS (how you do that is another subject i will try to explore later)
  • Uninstall the CAS and remove the database while uninstalling (that's an option)
  • Open the registry on SQLServer. backup- and delete the RegKey tree: HKLM\SOFTWARE\Microsoft\SMS
  • Install the CAS as a brand new Server with a brand new Database
  • Stop all SMS services on the newly installed CAS
  • Go to the SQL manager and connect to the SQLServer Database engine
  • From the Databases entry right click the newly created DB and select task Detach.
    • check drop connections
  • Now right click on Databases and select task restore Database; use the option Source - Device
  • Select Backup media type: File and click the Add button; browse to the browse with the ... button to the .BAK file of the Database Backup you have saved previously
  • SQL will check the BAK file and, if checks ok, will display its contents. if OK by you hit the OK button and the restore will start
  • After all this went well the CAS server should restart as soon as you open the CM12 management interface.
  • Now do install all Cumulative updates you have applied to the level you did on the previous CM12 configuration (the one before the crash or restore)
At this point your CAS should be fully functional again

My next post will focus on the restore of the Primary sites.