October 2009 - Posts

Hardware Inventory Customization - only specific environment variables

Based on this blog entry, a similar situation to getting just selected services, might be Environment Variables.  You could enable the default class for gathering all environment variables, but most computers have lots of Environment variables--most of which you don't really need to know the values of them.  Here's one way to pull back just those environment variable values you really care about.

 

fyi, depending upon what you are looking for, this inventory edit may not be the best solution, either.  If you know an environment variable has to equal a very specific value, you could use a Desired Configuration Management rule instead, and then just report on machines which are "non-compliant" based on your defined rules.  It all depends what you need--there are several ways to approach getting, and remediating if necessary, based on environment variable settings.

 

Below is a sample mof snippet to be added to sms_def.mof and configuration.mof (If you are SMS2003, add both to sms_def.mof or mini.mof, and use your normal mofcomp routine to tell your clients how to report). 
This example would be if the only values you wanted to know about were the environment variables of 'windir' and a custom environment variable of 'imagename'.  Possibly these two are poor examples...but I'm just trying to illustrate!

 

//==================================================================
//      Add to SMS_DEF.MOF
//==================================================================
#pragma deleteclass("Win32_EnvironmentLTD",NOFAIL)

[dynamic, provider("MS_VIEW_INSTANCE_PROVIDER"), SMS_Report(TRUE),
SMS_Group_Name("Win32_EnvironmentLTD"), SMS_Class_ID("CUSTOM|Win32_EnvironmentLTD|1.0")]
class Win32_EnvironmentLTD : SMS_Class_Template
{
                [SMS_Report(TRUE), key] String Name;
                [SMS_Report(TRUE), key] String UserName;
                [SMS_Report(TRUE)] String VariableValue;
};

//--------------------------------------------
// Add to Configuration.MOF
//--------------------------------------------
#pragma namespace("\\\\.\\root\\cimv2")

[Union, ViewSources{"select Name,UserName,VariableValue from Win32_environment where Name='windir' OR Name='imagename'"},ViewSpaces{"\\\\.\\root\\cimv2"}, dynamic,Provider("MS_VIEW_INSTANCE_PROVIDER")]
class Win32_EnvironmentLTD
{
    [PropertySources{"Name"},Key]
    string    Name;
    [PropertySources{"UserName"},Key]
    string    UserName;
    [PropertySources{"VariableValue"}]
    string    VariableValue;
};

 

Credits:  www.dudeworks.com (Dude!!) for the original idea.

Posted by skissinger | with no comments

Remote Regedit - Roger Zander Client Center

I've offered a similar solution previously, for Ron Crumbakers Web Remote Console 3.21 Here's an updated method that will work with Roger Zanders' Client Center.

If you do NOT have to support Windows 7 nor Windows Server 2008 or higher, you could use regedt32, for 1-click access, by doing 3 changes:

  1. Obtain a copy of regedt32.exe from an older OS.  The one I've used is file version 5.0.2195.6605, from Windows 2000.  Place regedt32.exe into c:\program files\Common Files\SMSCliCtr\Tools
  2. Place RemoteRegEdt32.vbs (you may want to right-click, save as... that link) into c:\program files\sccm tools\sccm client center
  3. Edit c:\program files\Common Files\SMSCliCtr\Tools\Plugin_Default.dll.config (in Notepad)
    a. Find the lines regarding CustCommand and CustArguments and change them to this:
            <setting name="CustCommand" serializeAs="String">
                <value>cscript</value>
            </setting>
            <setting name="CustCommandArguments" serializeAs="String">
                <value>RemoteRegEdt32.vbs {0}</value>
            </setting>
            <setting name="CustCommandText" serializeAs="String">
                <value>RegEdt32</value>
            </setting>
  4. Note: regedt32 does NOT work when the target is Windows 7 nor Server 2008. You can launch regedt32 from a Win7 or Server08 box, and target a remote computer which is a lessor OS version, however.

       
If you DO need to support Windows 7 or Server 2008 or higher:

  1. Forget regedt32.exe, and the .vbs.  Instead, Edit c:\program files\Common Files\SMSCliCtr\Tools\Plugin_Default.dll.config (in Notepad)
        a. Find the lines regarding CustCommand and CustArguments and change them to this:
      
            <setting name="CustCommand" serializeAs="String">
                <value>regedit</value>
            </setting>
            <setting name="CustCommandArguments" serializeAs="String">
                <value></value>
            </setting>
            <setting name="CustCommandText" serializeAs="String">
                <value>RegEdit*</value>
            </setting>

    b.  That will launch regedit and display your *local* computer.  You will have to remember to go to File, Connect to another Computer, and input the computer name of the target.

       
Notes or other Caveats

  • Why do we use an older regedt32?  Because the newer regedit doesn't have a command line way, or a cheesy workaround, to initiate a connection to a remote computer.  With the lateer regedit, you would have to go to File, Connect to another computer.  With Regedt32, by manipulating some CurrentUser keys, you can fake it into connecting to the remote computer at launch.
  • This Custom Command does not pass in "Alternate Credentials" If you had selected Options... and unchecked "Use Integrated Authentication" and provided alternate credentials.  If you normally run Client Center as a low-rights ID, and then use Options to switch to a higher rights ID, or an account in another domain, you may need to do the following:
       > In c:\program fiels\sccm tools\sccm client center, right-click smsclictrv2.exe and Send To... Desktop (create a shortcut)
       > On the newly created shortcut, Shift + Right-click to RunAs... and input your alternate credentials.
  • The target computer must have Remote Registry enabled, and the appropriate firewall ports open as necessary to allow for remote registry connection.
  • Testing/setup was done using Roger Zanders' Client Center version 2.0.1.8; if an earlier version, you may need to update.
Posted by skissinger | 3 comment(s)
Filed under: