Jeff Gilbert's Web blog at myITforum.com

This posting is provided "AS IS" with no warranties, and confers no rights :-)
About the #Pragma Deleteclass command

The #pragma deleteclass command is used in SMS/Configuration Manager hardware inventory modification to delete class information from WMI repositories. There are a couple of instances where this command comes in handy. If you are testing new hardware inventory modifications, and making changes to your mof edits during testing, you'll want to start off with a clean slate each time the client compiles the new mof file to avoid unforseen consequences. Or maybe you've just decided that you don't want to clutter up client WMI repositories with unnecessary class information and just want to delete it.

Note: When deleting WMI classes from clients that have already performed hardware inventories (especially if you have changed a Key field), you should also delete the class information stored in the site database as well. I won't go into that here, but Microsoft's delgrp.exe (involves going into SQL Server) and SMS Expert's SiteSweeper (easy way) can be used for that.

To delete the unneeded classes from a client's local system WMI repository, you need to manually compile a modified MOF (SMS_def.mof or 'mini-mof' for SMS 2003) or add the lines to the Configuration.mof (Configuration Manager) containing the now famous #pragma deleteclass line. Just open up your MOF/'mini-mof' and comment out the entire section for your targeted class-or delete the class totally and roll the dice that you'll never need it again.  Make sure you use the #pragma deleteclass command on both the data and reporting classes as in the example below:

#pragma namespace("\\\\.\\root\\CIMV2")
#pragma deleteclass("ClassIDontLikeAnymore",NOFAIL)
#pragma namespace("\\\\.\\ROOT\\CIMV2\\SMS")
#pragma deleteclass("ClassIDontLikeAnymore",NOFAIL)

/*
...ClassIDontLikeAnymore information that I used to like, but now I don't. I've commented
it out in case I ever make friends with ClassIDontLikeAnymore again...
*/

P.S. Do not delete a data class unless you created it! 

Published Saturday, August 25, 2007 5:38 PM by jgilbert

Comments

# re: About the #Pragma Deleteclass command@ Friday, October 10, 2008 11:14 AM

So is it possible to delete a single column instead of a whole class?  For example, we're collecting extra user information from AD using VBScript.  It uses DDRs to get the data in a semi-supported way into v_R_User, but the company changed some of the fields that are available in AD and a few of them no longer exist.  Instead of having 4-5 columns that have no data, I'd like to remove them, but I don't know how without messing up v_R_User for everyone else.  Obviously directly editing the User_DISC table is out.  Any help as to which way I can go?  I also see this as a big deal going forward too because we have a child company that is going to stay on SMS 2003 while we go to CM, but they have to tie into our reporting site and we'll get all of their crappy custom classes that eventually we'll want to delete.  I'd like to know how to properly delete columns/fields that were once created with a custom inventory class, without deleting the whole class.  THANKS!

jnelson