question

JoshuaReynolds-6825 avatar image
0 Votes"
JoshuaReynolds-6825 asked SimonRenMSFT-3639 edited

Extending Hardware Inventory to read a registry key

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;
 };



mem-cm-general
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Garth avatar image
1 Vote"
Garth answered

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

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

SherryKissinger-ECM avatar image
1 Vote"
SherryKissinger-ECM answered SherryKissinger-ECM edited

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".

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

SimonRenMSFT-3639 avatar image
0 Votes"
SimonRenMSFT-3639 answered SimonRenMSFT-3639 edited

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://docs.microsoft.com/en-us/answers/articles/67444/email-notifications.html

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.