Skip to content

Deploying Software with Unique Keys

Featured Replies

We are in the process of getting our first SCCM server in place and running. We have our typical software packages created and ready to go. However, I am wondering how everyone manages software that requires unique keys.

 

Specifically something like Adobe Acrobat Pro, PhotoShop, SnagIT, etc... We only have a few copies of this software and each one has it's own individual keys.

 

Thanks in advance

The easiest way would be to create a SQL database with only one table and 2 fields. One holding the license key and the other one the workstation name. Then create a script wrapper for your installation, which searchs in you your database for a free license.

 

1 - Look up for client name in the database and if found use the corresponding license.

- If the client name was not found look for next free license (workstation=Null)

- Block the license by writing the client name to the workstion field.

 

2 - pass the license key property to the installation command SERIALNUMBER=xxxx-xxxx-xxxx-xxxx

  • 3 months later...

No Problem. Here is a short powershell script which checks an SQL database for the License and performs the installation if a free key was found.

 

#################################################

# Define SQL Login Credentials and Connection Details here

$Server = "SQLSERVER"

$Database = "DATABASE"

$Username = "USERNAME"

$Password = "PASSWORD"

$Connect = New-Object System.Data.SqlClient.SqlConnection("Data Source=$Server; Initial Catalog=$Database; User Id=$Username; Password=$Password;")

$Connect.Open()

$Hostname = $Env:COMPUTERNAME.toUpper()

$ExitCode = 0

# Let's see if we can connect to the Database

if($Connect.State -eq "open"){

# Great. Now let's check if the Hostname has a License assigned already

$cmd = $Connect.CreateCommand()

$cmd.CommandText = "SELECT License From Licenses1 Where Client='$Hostname'"

$Result = $cmd.ExecuteReader()

If($Result.Read()){

Write-Host "Hostname Found In Database. Using Assigned License."

$License = $Result.GetValue(0)

$Result.Close()

}

Else {

$Result.Close()

# No Problem. Maybe we can find a free License.

Write-Host "Hostname Not Found In Database. Checking For Free Licenses."

$cmd.CommandText = "SELECT TOP 1 License From Licenses1 Where Client Is NULL"

$Result = $cmd.ExecuteReader()

If($Result.Read()){

Write-Host "Using Free License From Database."

$License = $Result.GetValue(0)

$Result.Close()

#Whoop Dee Doo. We got a free License. Let's block and use it.

$cmd.CommandText = "UPDATE Licenses1 SET Client='$Hostname' Where License='$License'"

$retcode = $cmd.ExecuteNonQuery()

If($retcode -eq 1){

Write-Host "Assigned License to Host."

}

Else {

# What the heck just happened here!

Write-Host "Failed To Write Changes To Database"

}

}

Else {

$Result.Close()

# Shit happens. Let's buy some more Licenses and try again.

Write-Host "Error: No Free Licenses in Database."

$ExitCode = 2279 # Your Own Error Code Here

[Environment]::Exit($ExitCode)

}

}

$installParameters = "/i MSINAME.msi TRANSFORMS=MSTNAME.mst REBOOT=ReallySuppress SERIALNUMBER=$License /norestart /qn"

$Connect.Close()

$ExitCode = (Start-Process -FilePath "msiexec.exe" -ArgumentList $installParameters -Wait -Passthru).ExitCode

If ( $ExitCode -eq 3010 ) { $ExitCode = 0 }

If ( $ExitCode -eq 0 ) {

Write-Host "Success: Finished Installation with Return Code 0"

}

Else {

Write-Host "Error: Aborted Installation with Return Code $ExitCode"

}

}

Else {

# Must be Patch Day or something like that

Write-Host "No Connection To SQL-Server"

$ExitCode = 2277 # Your Own Error Code Here

}

Write-Host ".... I'm done. Let's exit now."

[Environment]::Exit($ExitCode)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.