How to Find Your OfficeWriter License Keys

First Things First: What do we have, and where is it?

If you’ve ever gone through a licensing review or license audit, you know that sometimes the hardest part of the whole process is information gathering. What keys do you have? Where are they installed? What is still under support, and what is not? Are we overpaying or over-provisioned? These questions and more can drive a sysadmin to insanity, especially if your records are less than perfect.

While no method can substitute for proper record keeping, I’m here to show you how to find any OfficeWriter product keys that may be installed on your servers. Basically, what I am looking to do is get a list of license keys, versions, and where they are.

Prerequisites

SoftArtisans stores all of its license keys in HKCR:\Licenses\Softartisans. We could manually open RegEdit on all our machines and find the keys, then copy them out into an Excel spreadsheet, but that would take WAY too long, even for my development environment.

Before we begin scripting, I first got a list of all the machines I wanted to check. (To save time I just took my whole testing domain – “Get-ADComputer –Filter * | Select {$_.DNSHostName} | Out-File Computers.txt” – then trimmed the headers; however, you will probably want to adjust the filter appropriately.) This is the list that I will use to see what has OfficeWriter installed:

OfficeWriter Licenses

You’ll also want the Powershell ISE or another appropriate text editor handy.  (We could do this in Notepad, but it’s not ideal.)

Enumerating Our Registry Keys

To get the Registry Keys for a single computer, we have several options. We could mount the Registry share using the Registry PSProvider, or WMI StdRegProv. I, however, chose to leverage my favorite feature of PowerShell: the .NET API.

Function Get-OWKeys([string]$computer){

$keyList = @()

$rootkey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey(“ClassesRoot”,$computer)

if(-not $rootkey) { Write-Error “Can’t open $computer remote registry hive”; return }

$key = $rootkey.OpenSubKey(“Licenses\Softartisans”)

if(-not $key) { Write-Error “Can’t find Keys on $computer:”; return }

$keys = $key.GetSubKeyNames()

If($keys -ne $null) {

ForEach ($regkey in $keys){

$reg = $key.OpenSubKey($regkey)

$objKey = New-Object System.Object

$objKey | Add-Member -Type NoteProperty -name Product -value $regkey

$objKey | Add-Member -Type NoteProperty -name Key -value $reg.GetValue(“PAK”)

$objKey | Add-Member -Type NoteProperty -name Host -value $computer

$keyList += $objKey

}

}

return $keyList

}

Here, given a computer, I loop through the registry, first failing on connection, then failing if I can’t find the keys. Then, if I find any installed SoftArtisans Product Keys, write them into a custom PSObject that holds the values that I want.  Now, I could just call that in a script from each machine, but I’ve already got a list of machines. Let’s just do it all at once.

Repeating Over and Over again.

Now that I have my Get-OWKeys function, I simply added the following code to call it for our list. Note that I’ve added a GUI file manager dialog, but using a Read-Host Command works just fine.

Function Get-File($startDir)

{

[System.Reflection.Assembly]::LoadWithPartialName(“System.windows.forms”) |

Out-Null

$dialog = New-Object System.Windows.Forms.OpenFileDialog

$dialog.initialDirectory = $initialDirectory

$dialog.ShowDialog() | Out-Null

$dialog.filename

}

$computerList = Get-Content $(Get-File -startDir “~\Desktop”)

$CustomerKeys = @()

foreach($computer in $computerList)

{

Write-Host “Processing $computer…”

$CustomerKeys += Get-OWKeys -computer $computer

}

$CustomerKeys | FT

There you have it, your OfficeWriter license keys in a nice neat table.

OfficeWriter Licenses

If you want to pipe it into a CSV for later processing, simply pipe run the following command instead:

“.\GetOWLicenses.ps1 |FL|Export-CSV .\OfficeWriter-Licenses.csv”

Related posts: