Enabling Inventory for Environment Variables - SMS2003/ConfigMgr
I often receive queries about extending the MOF to pull in regkeys. Occasionally, those regkeys happen to be located in HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
Instead of creating a custom mof edit to pull in a value contained in that regkey; most Environment variables are also stored in WMI, in win32_environment; and the default sms_def.mof does have an existing segment to pull in those values. By default, that segment is set as FALSE . To enable inventorying of Environment variables:
-
For paranoia, backup \inboxes\clifiles.src\hinv\sms_def.mof
-
Using a log file viewer, (like trace32.exe from the sms toolkit), open up sms\logs\dataldr.log
-
edit sms_def.mof using notepad
-
Search for "Environment" and change that section from having FALSE to be TRUE for at least the following. They can all be TRUE; but (at least for me) those additional values were not useful for the queries and reports I needed.
[ SMS_Report (TRUE),
SMS_Group_Name ("Environment"),
SMS_Class_ID ("MICROSOFT|ENVIRONMENT|1.0") ]
class Win32_Environment : SMS_Class_Template
{
[SMS_Report (FALSE) ]
string Caption;
[SMS_Report (FALSE) ]
string Description;
[SMS_Report (FALSE) ]
datetime InstallDate;
[SMS_Report (TRUE), key]
string Name;
[SMS_Report (FALSE) ]
string Status;
[SMS_Report (TRUE) ]
boolean SystemVariable;
[SMS_Report (TRUE), key]
string UserName;
[SMS_Report (TRUE) ]
string VariableValue;
};
You have now triggered a Hardware Inventory Policy change. You now simply need to wait--you are waiting for this policy to be compiled and forwarded to your Management Points, and then you are waiting for your clients to pick up this policy change, and then for the clients to run a Hardware Inventory action, using the new policy, and forward the new information to SMS or ConfigMgr. How long those actions take depends upon your SMS/ConfigMgr environment.
If you are impatient, you can spot-check a test client by:
-
Wait a few minutes for the policy change to be complied and forwarded to your Management Points
-
At a client, perform a "Machine Policy Retrieval and Evaluation Cycle" Action; wait ~2 minutes for retrieval to complete.
-
At a client, perform a "Machine Policy Retrieval and Evaluation Cycle" Action; wait ~2 minutes for evaluation of the just-received new policies.
-
At a client, perform a "Hardware Inventory" action.
-
Monitor the client log file windir\system32\ccm\logs\inventoryagent.log; you will be looking for something like "Select Name, SystemVariable, UserName, VariableValue from win32_environment" to be requested. If you do not see that line; either your editing of the SMS_DEF.MOF was rejected and the one containing "FALSE" for that class was replaced from backup automatically, or you need to do another "Machine Policy Retrieval and Evaluation Cycle"; and another "Hardware Inventory" action.
Once clients begin reporting on this new class, you will be able to create queries, collection queries, or reports on Environment variables.