Extending Hardware Inventory to read a registry key

Joshua Reynolds 1 Reputation point
2021-08-06T05:13:07.747+00:00

Hi I don't have a test SCCM server to check this out on so thought I'd run it past the lovely forum to check I'm writing this up correctly before implementing it.

I have a few requirements from a security compliance to start logging and double checking things. Figure I would start with an easy regkey check one to learn the process (knowing things like this could be config items).

The goal is to read the PowerShell version keys against every device and see what exists out there. I'm writing up the modification I would compile within the Configuration.MOF file running through this guide http://schadda.blogspot.com/2012/02/sccm-2012-customize-extend-hardware.html

I'm placing it in the add extensions section and it looks like the below. Does this ring true or am I making a newbie mistake?

//=======================================================
// Microsoft Powershell Version
//=======================================================

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

#pragma deleteclass("Win32Reg_SMSPowerShellVersion", NOFAIL)

[DYNPROPS]
class Win32Reg_SMSPowerShellVersion
{
    [key] string PowerShellVersion;
        string PowerShellVersionV2;
        string PowerShellVersionV3
};

[DYNPROPS]
instance of Win32Reg_SMSPowerShellVersion
{
    InstanceKey = PowerShellVersion";
    [PropertyContext("local|HKEY_LOCAL_MACHINE\\Software\\Microsoft\\PowerShell\\1|PowerShellVersion"),
                    Dynamic, Provider("RegPropProv")]
        PowerShellVersionV2;
    [PropertyContext("local|HKEY_LOCAL_MACHINE\\Software\\Microsoft\\PowerShell\\3|PowerShellVersion"),
                    Dynamic, Provider("RegPropProv")]
        PowerShellVersionV3;
};
Microsoft Configuration Manager
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Garth 5,801 Reputation points
    2021-08-06T11:26:10.807+00:00

    Yes it looks right. But you should use regkey2mof. https://askgarth.com/blog/how-to-use-regkeytomof-2/ a lot easier

    1 person found this answer helpful.
    0 comments No comments

  2. Sherry Kissinger 4,051 Reputation points
    2021-08-06T14:25:41.56+00:00

    Or... steal my inventory edit: https://tcsmug.org/blogs/sherry-kissinger/300-configmgr-inventory-of-powershell-versions

    Edit: Just noticed that if you just-so-happened to have installed Powershell 7 (where you would run pwsh.exe, not powershell.exe nor powershell_ise.exe from the %windir% folder); that is recorded elsewhere.

    So depending upon "which question" you are asking, you might have a multi-layered answer when someone asks the question about "what version of Powershell is installed".

    1 person found this answer helpful.
    0 comments No comments

  3. Simon Ren-MSFT 31,221 Reputation points Microsoft Vendor
    2021-08-12T07:39:59.903+00:00

    Hi,

    Hope everything goes well. May we know the current status of the question? If there is any chance to try above suggestions? If there is any other assistance we can provide, please feel free to let us know, we will do our best to help you.

    Thanks and regards,
    Simon


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
    https://learn.microsoft.com/en-us/answers/articles/67444/email-notifications.html

    0 comments No comments