Saturday, April 24, 2010

SCCM on XENDesktop or PVS Standard Target Devices

By:Rick Rohne
Have you ever tried to manage your XENDesktop or PVS target devices using SCCM? In some ways, managing the devices using SCCM is irrelevant due to the nature of how PVS works, but low and behold, I've run into a few companies that insist on using SCCM for inventory management and application installation. The SCCM client, however, does not work well in a streamed OS environment. If you've ever tried installing the SCCM client on a PVS image, you will notice that SCCM shows new machines with the same name in its collections every time a PVS target device reboots in standard mode. This is because the SCCM client changes the GUID when an imageis pushed to new hardware. SCCM uses the GUID to keep track of Physical Hardware devices.

Overview how SCCM works
To give you an idea how it works, SMS uses the GUID of the computers to associate the Computer and OS with the SMS object. This GUID is stored in the c:\windows\SMSCFG.ini file.

The GUID can be read from this file, also by querying WMI using this vb script.
strComputer = "."
strNameSpace = "root\ccm" strClass = "CCM_Client=@" Set objClass = getObject("Winmgmts:{impersonationlevel=impersonate}!\\" & strComputer & "\" & strNameSpace & ":" & strClass)
strGUID = objClass.ClientID
Wscript.Echo strGUID
Set objClass = Nothing
The problem we see is in a Citrix Provisioned desktop, this file comes up with a duplicate GUID each time. This causes the SCCM client t re-generate theGUID and create a new file on every boot.
You can find this information here

The Fix
In order to persist the computers GUID, you must be using “cache to targets hard drive” when you place your systems in standard mode. We use the hard drive to save the SCCMCFG.ini file after each reboot.
This also means that "cache to RAM" or "cache to Server" will not be sufficient because the cache will be purged on every reboot.

Step 1.
To resolve this, first, you have to run a script when switching from private mode to standard mode. This is done by the XENDesktop Admin after he modifies the default image…
This script stops the SCCM service and deletes the c:\windows\SCCMCFG.ini file.
'--------------------------- SCCM Cleanup.vbs--------------------------------------
'Stop SCCM client strServiceName = "CCMExec"
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colListOfServices = objWMIService.ExecQuery("Select * from Win32_Service Where Name ='" & strServiceName & "'")
For Each objService in colListOfServices objService.StopService() Next ' Cleanup SCCM Set fso = CreateObject("Scripting.FileSystemObject") Set aFile = fso.GetFile("c:\windows\SMSCFG.ini") aFile.Delete
Step 2.
Now, you have to run a shutdown script and startup script that basically places the c:\windows\SCCMCFG.ini file on the Cache drive on shut down. When the computer boots up, it will check to see if the file exists on the cache drive. If it does not, the SCCM client will register itself to the SCCM server and create a new c:\windows\SCCMCFG.ini file. Upon shutdown, the c:\windows\SCCMCFG.ini file is copied to the cache drive.

This is a simple batch file script that can be loaded into active directory as a computer startup script for the OU where XENDesktop computers reside.

Startup Script
IF EXIST G:\SMSCFG.ini COPY G:\SMSCFG.ini C:\Windows\SMSCFG.ini /y > c:\smserror.txt

Shutdown Script
COPY c:\windows\SMSCFG.ini G:\SMSCFG.ini /y > g:\smserror.txt

Now computers that are manged by SCCM will show up as unique entries in the SCCM database.
NOTE: This was tested with SCCM 2007 R2, PVS 5.1, and XENDesktop 4

More information on Provisioning Server
blog comments powered by Disqus
Microsoft Virtualization, Citrix, XENServer, Storage, iscsi, Exchange, Virtual Desktops, XENDesktop, APPSense, Netscaler, Virtual Storage, VM, Unified Comminications, Cisco, Server Virtualization, Thin client, Server Based Computing, SBC, Application Delivery controllers, System Center, SCCM, SCVMM, SCOM, VMware, VSphere, Virtual Storage, Cloud Computing, Provisioning Server, Hypervisor, Client Hypervisor.