Jump to content


BzowK

Inventory Strings Within Dynamically Named Registry Key

Recommended Posts

Hey Guys / Niall -


I recently wrote and compiled a script which when executed on a workstation, will write a few registry strings to a custom key within the registry. The goal of this script is to inventory this data using SCCM. I think the issue I'm having is that by design, the script writes these values into a key which is named after the currently logged in user therefore is dynamic per system.


I've tried using RegKeytoMOF and have looked at many pages like this one for how to add classes to inventory by editing MOF files, but haven't had luck. When using RegKeytoMOF and selecting the key named after the username, the MOF files it creates seem to populate correctly as I can clearly see each string within defined. I cannot use this as the key would be different per system so would assume I need to select the parent key. However, when I select the parent key of "ProfileInfo", the generated MOF files do not contain any settings nor mention "ProfileInfo."


So - how do I go about doing this? Is the below correct? Thank you!


Example of What I'm Trying to Inventory


All Strings within: HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Company\ProfileInfo\gwashington


DocumentsSize = 100

DesktopSize = 50

MyProfile = 800

FavoritesSize = 0

AllProfilesSize = 1200


"HKLM\SOFTWARE\Wow6432Node\Company\ProfileInfo" would be the same on all PCs, but the key "gwashington" shown above is named after the logged in user so would be dynamic / different per system. All strings would be named the same within the user's key, but would obviously have different values per PC.


RegKeytoMOF Output When "gwashington" Key Selected

ClassGroup & ClassName set to "ProfileInfo"


// RegKeyToMOF by Mark Cochrane (tribute to Skissinger & Steverac)

// this section tells the inventory agent what to collect

#pragma namespace ("\\\\.\\root\\cimv2")

#pragma deleteclass("ProfileInfo", NOFAIL)

[DYNPROPS]

Class ProfileInfo

{

[key] string KeyName;

String MyDocuments;

String Desktop;

String Favorites;

String AppData;

String MyProfile;

String AllProfiles;

String MyNetworkShare;

};


[DYNPROPS]

Instance of ProfileInfo

{

keyname="RegKeyToMOF[MarkCochrane]";

[PropertyContext("Local|HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Company\\ProfileInfo\\gwashington|MyDocuments"),Dynamic,Provider("RegPropProv")] MyDocuments;

[PropertyContext("Local|HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Company\\ProfileInfo\\gwashington|Desktop"),Dynamic,Provider("RegPropProv")] Desktop;

[PropertyContext("Local|HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Company\\ProfileInfo\\gwashington|Favorites"),Dynamic,Provider("RegPropProv")] Favorites;

[PropertyContext("Local|HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Company\\ProfileInfo\\gwashington|AppData"),Dynamic,Provider("RegPropProv")] AppData;

[PropertyContext("Local|HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Company\\ProfileInfo\\gwashington|MyProfile"),Dynamic,Provider("RegPropProv")] MyProfile;

[PropertyContext("Local|HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Company\\ProfileInfo\\gwashington|AllProfiles"),Dynamic,Provider("RegPropProv")] AllProfiles;

[PropertyContext("Local|HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Company\\ProfileInfo\\gwashington|MyNetworkShare"),Dynamic,Provider("RegPropProv")] MyNetworkShare;

};


RegKeytoMOF Output When "ProfileInfo" (Parent) Key Selected

ClassGroup & ClassName set to "ProfileInfo"



// RegKeyToMOF by Mark Cochrane (tribute to Skissinger & Steverac)

// this section tells the inventory agent what to collect

#pragma namespace ("\\\\.\\root\\cimv2")

#pragma deleteclass("ProfileInfo", NOFAIL)

[DYNPROPS]

Class ProfileInfo

{

[key] string KeyName;

};


[DYNPROPS]

Instance of ProfileInfo

{

keyname="RegKeyToMOF[MarkCochrane]";

};



Thanks!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.