I’ve been getting a lot of request for this in my trainings, so here it is. 
At the end of this post, you will have all the tools you need to track your Windows product keys and Microsoft office product keys. 
They way this works is we find the keys using nirsoft's keyfinder program. 
Next a VBS writes the keys to the registry. 
Finally we tie it all together with custom inventory rules. 

Requirements:Product Finder (now form Nirsfot) 
Here is the link to the portable version
http://www.nirsoft.net/utils/produkey.zip 

First thing we need to do is copy this VBS code into notepad and save it as keys.vbs 

Option Explicit

Dim objFSO			
Dim objTextFile
Dim winKey 
Dim officeKey
Dim strFile
Dim arrKeys
Dim i

Const ForReading = 1
Const winCDLine = "Windows"
Const officeCDLine = "Microsoft Office"
Const noViso = "Visio"
Const officeKeyReg = "offKey"
Const winKeyReg = "winKey"


Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
    ("keys.csv", ForReading)

'Read the file into the array
strFile = objTextFile.ReadAll
arrKeys = Split(strFile, vbCrLf)

For i = LBound(arrKeys) To UBound(arrKeys)
	'try to find the windows product key
	If(instr(arrkeys(i),winCDLine))Then
		winKey = getKey(arrKeys(i))
		writeReg winKey,winKeyReg	
	End If
	'try to find the office product key
	If(InStr(arrKeys(i),noViso)) Then
	
	ElseIf(InStr(arrKeys(i),officeCDLine)) Then
		officeKey = getKey(arrKeys(i))
		writeReg officeKey,officeKeyReg
	End If
Next

Function getKey(strKeyLine)
Dim temper
Const KeyLoc = 2
Const ProdLoc = 0

temper = Split(strkeyLine,",")
getKey = temper(prodloc) & "_" & temper(KeyLoc)

End function


Sub writeReg(strValue,StrValueName)

Dim strComputer
Dim oReg
Dim wshShell

Const HKEY_LOCAL_MACHINE = &H80000002
Const strKeyPath = "SOFTWARE\TVG"
Const strKeyPath64 = "SOFTWARE\Wow6432Node\TVG"
Const is64Key = "SOFTWARE\Wow6432Node"

strComputer = "."

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _ 
    strComputer & "\root\default:StdRegProv")
Set WshShell = WScript.CreateObject("WScript.Shell")

'check for 64 bit
If(OS64()) Then
	oReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath64
	oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath64,strValueName,strValue
Else
	oReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath
	oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
End If

End Sub

Function OS64()
Dim objOS
Dim colItems
Dim objItem
Dim strComputer

strComputer = "."
Set objOS = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objOS.ExecQuery("SELECT OSArchitecture FROM Win32_OperatingSystem")

'this should fail on 32 bit XP
On error resume next
For Each objItem In colItems
	If(IsNull(objItem.OSArchitecture)) Then 
		OS64 = False
	ElseIf(InStr(objItem.OSArchitecture,"64") > 0) Then
		OS64 = True
	Else 
		OS64 = False
	End If
Next
On Error Goto 0

If(Err <> 0) Then 
	OS64 = False
End if
End Function
 
Next thing we need to do is go to the scripting module and a new script. 
For script type select Online Shell Script. 
Choose a label, select windows as the operating system and set the script to run as local system. 
Next upload produkey.cfg, produkey.exe (both found in the nirsoft folder, make sure you unzip) and keys.vbs as dependencies. 
For the script text enter the following 2 lines. 
ProduKey.exe /windowskeys 1 /officekeys 1 /iekeys 0 /sqlkeys 0 /exchangekeys 0 /extractedition 1 /scomma keys.csv
cscript.exe keys.vbs


Last thing we need to do is change the script name from script.sh to script.bat (just below the script text). 

Now that we have the keys in the registry we can start creating the custom inventory rules. 
Go to the software module and add a new item. 
Call the first one “Windows Product Key” 
Select all your windows operating systems for supported OSs. 
Finally here is the syntax for the custom inventory rule: 
RegistryValueReturn(HKEY_LOCAL_MACHINE\SOFTWARE\TVG,winKey,TEXT)

Go ahead and save the software. 
Next add another item but this time call it "Microsoft Office Key" 
Highlight all the windows OSs again. 
Here is the syntax for the second piece of software. 
RegistryValueReturn(HKEY_LOCAL_MACHINE\SOFTWARE\TVG,offKey,TEXT)


At this point you could also create additional software records, for example one for each office key. 
That way depending on the key you would have a unique software title. This way you could use the KBOXs built in asset management module and do licence compliance. 

Below are two reports that you can use to see what machines have what keys installed. 
Office report: 
SELECT M.NAME,
       SUBSTRING_INDEX(MCI.STR_FIELD_VALUE,'_',1) AS OFFICE_VERSION,
       SUBSTRING_INDEX(MCI.STR_FIELD_VALUE,'_',-1) AS PRODUCT_KEY
FROM   SOFTWARE S,
       MACHINE_CUSTOM_INVENTORY MCI,
       MACHINE M
WHERE  MCI.SOFTWARE_ID = S.ID 
       AND M.ID = MCI.ID
       AND S.DISPLAY_NAME = 'Microsoft Office Key'
ORDER  BY OFFICE_VERSION,
          PRODUCT_KEY


Windows report: 
SELECT M.NAME,
       SUBSTRING_INDEX(MCI.STR_FIELD_VALUE,'_',1) AS WINDOWS_VERSION,
       SUBSTRING_INDEX(MCI.STR_FIELD_VALUE,'_',-1) AS PRODUCT_KEY
FROM   SOFTWARE S,
       MACHINE_CUSTOM_INVENTORY MCI,
       MACHINE M 
WHERE  MCI.SOFTWARE_ID = S.ID 
       AND M.ID = MCI.ID 
       AND S.DISPLAY_NAME = 'Windows Product Key'
ORDER  BY WINDOWS_VERSION,
          PRODUCT_KEY


I hope this is useful. 
Thanks to vacuna for helping me put this together.