I recently implemented a mechanism for collecting warranty end dates using a script which added the date to a registry key, then using hardware inventory to collect the key into SCCM SQL DB.
This is useful if there is information about a client machine which is not stored in WMI.
It worked great and proved a good method of collecting data, In this post i will cover the whole process in detail :
Step 1 – The Script
The first stage is creating a powershell, vbscript or bat file to grab the custom property you are looking for and write it to a registry key. I won’t go into the detail of doing that in this post. I am using a script which reads the setupact.log file in C:\Windows\Panther and returns whether the machine firmware is BIOS or EFI (UEFI) – then writes the info to a reg key. I couldn’t find a field in the registry or in WMI on Windows 7 which stores this information. (Hence the script and this post!)
Step 2 – The Deployment
The script needs to be deployed and run on every machines we want to collect information from. I find it easiest to create a source folder, place the powershell script in there and create a bat file ‘wrapper’ to call the powershell script and temporarily change the execution policy.
powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -WindowStyle Hidden -File "script.ps1" >> "%temp%\script.log"
For the detection method, use the following :
- Setting Type: Registry
- Hive: HKEY_LOCAL_MACHINE (or other if you are using different hive)
- Key: SOFTWARE\CompanyName\YourKey (this is the key you have written your info too)
- Value: NameOfKey
- Data Type: String (or other if you are using different data type)
- I used “This registry setting must satisfy the following rule to indicate the presence of this application”
- Operator “Not equal to”
- Value: <blank>
Sometimes my script would fail to gather the info required but would create the key with null value, i didnt want my detection rule to be satisified by this. (I know i was lazy and should have added more error checking the script! But this had the same outcome….)
Step 3 – The Mof File
Great! We have the info in the registry, but now we want to add it to the SCCM DB – for ease of querying and reporting etc…
This method was inspired by this brilliant post – https://sccmguru.wordpress.com/2014/04/24/hp-and-lenovo-warranty-information-in-configuration-manager-2012-r2/
I suggest using the methods described in the above post to create your MOF file and import the changes into ConfigMgr.
Step 4 – The Result
Once you have deployed the hardware inventory custom settings, the deployment has run on some machines and hardware inv has run you should have some results! If not, something is wrong, retrace your steps and check for mistakes…