How to Dynamically Change Autodesk License Type with PowerShell

dynamically update autodesk license

I have to assume that the forced change to a Named User Autodesk License is not unique to just us. I would imagine there are several other admins out there dealing with the same changeover. One challenge then was to have to deal with changing every PC in the company over to a non-network license configuration.

Rather than trying to explain all the steps to each employee, we wanted to script the changeover and make it as seamless as possible. As a result, I was able to write this script to make that process possible. Since I assume we aren’t the only ones, I wanted to share it in case others needed it as well. Of course, it is in PowerShell, because that is my language of choice.

DISCLAIMER

Please understand that the content herein is for informational purposes only. This existence and contents shall not create an obligation, liability or suggest a consultancy relationship. In further, such shall be considered as is without any express or implied warranties including, but not limited to express and implied warranties of merchantability, fitness for a particular purpose and non-infringement. There is no commitment about the content within the services that the specific functions of the services or its reliability, applicability or ability to meet your needs, whether unique or standard. Please be sure to test this process fully before deploying in ANY production capacity, and ensure you understand that you are doing so at your own risk.

Table of Contents

Autodesk Documentation
The Script
Conclusion


Autodesk Documentation

Autodesk has documentation on this process, and it isn’t too difficult to work with. However, it is lacking a few things that didn’t quite work for me, so I worked through PowerShell to fix them. These are the two main reasons for this post.

  1. Autodesk’s license tool is a traditional command line too. Totally fine, just not my preference. However, because it is text based, I switched to PowerShell so I could work with it in a way that I was more familiar with. Plus, this made it easier to deploy via Intune.
  2. I also needed this to work dynamically, since there are several different years and packages installed across the workforce. I didn’t want to make a big list containing all of them and hope I didn’t miss any. Better to search dynamically, and let the script do the work for me.

Additionally, you’ll notice with this Autodesk License tool, that there are more than just USER based license options. That is what I needed given that we were forced to switch. However, you can also use “” instead of USER in the script below to allow the user to choose what option they want. Or if you review the documentation, you can tweak this script to fit whatever needs you have.


The Script

The last line of the script includes some clean-up for older Autodesk software’s (2019 and older…). Because of where the clean-up is located, you’ll need to make sure this runs with Admin rights. If you don’t have older software, you can probably safely delete that line, but it doesn’t hurt so you don’t need to remove it if you don’t want to.

I will always keep the latest version of this script on my GitHub. However, below is the script in its current form as of when this is posted.
Reset-AdskLicensing.ps1 · SeeSmitty/Powershell (github.com)

Reset-AdksLicensing.ps1

#required first step, starts by removing their current login state from the Desktop App
Get-ChildItem "$env:localappdata\Autodesk\Web Services\LoginState.xml" -ErrorAction SilentlyContinue | Remove-Item -Force 


#Function to reset the license model for each item in the list
function Reset-AdskCloudLicense($ar) {
    Start-Process -FilePath "${env:ProgramFiles(x86)}\Common Files\Autodesk Shared\AdskLicensing\Current\helper\AdskLicensingInstHelper.exe" -ArgumentList $ar | Out-Null
}

#set the location so we can run the file to get the list of products on the machine 
Set-Location "${env:ProgramFiles(x86)}\Common Files\Autodesk Shared\AdskLicensing\Current\helper\"
$list =  .\AdskLicensingInstHelper.exe list


#select the string to pull the keys out of the text that is generated
$Key = $list | Select-String def_prod_key
$key = foreach($l in $key){([String]$l).Trim('"def_prod_key": ')}
$key = foreach($l in $key){([String]$l).Trim('",')}

#select the string to pull the version out of the text that is generated
$ver = $list | Select-String def_prod_ver
$ver = foreach($l in $ver){([String]$l).Trim('"def_prod_ver": ')}
$ver = foreach($l in $ver){([String]$l).Trim('",')}

#creates a datatable to make it easier to process and parse the data
$Actiontable = New-Object System.Data.DataTable
$Actiontable.Columns.Add("def_prod_key", "System.String")
$Actiontable.Columns.Add("def_prod_ver", "System.String")

#adds a new key to the datatable while also adding the cooresponding version 
#it is incremented by one each time the loop is ran
#confirmation that the keys & versions are still lined up can be found with this command: $list | Select-String def_prod_key,def_prod_ver
$x = 0
foreach($k in $key){
    $arow = $Actiontable.NewRow()
    $arow.def_prod_key = $k
    $arow.def_prod_ver = $ver.split()[$x]
    $Actiontable.Rows.Add($aRow)
    $x += 1
}

#creates the final array of arguments we will use in the actual license type reset
#Should be one of (case insensitive): USER, STANDALONE, NETWORK or empty "" to reset LGS
$finalArray = @()
foreach($a in $Actiontable){
    $prodkey = $a.def_prod_key
    $prodVer = $a.def_prod_ver
    $finalArray += "change -pk $prodKey -pv $prodVer -lm USER"
}

#applys the actual reset
foreach($final in $finalArray){
    Reset-AdskCloudLicense -ar $final
}


#cleans up the license folder once all is said and done to remove any unwanted license items. 
#Primarily for Autodesk 2019 and older products
Get-ChildItem "$env:ProgramData\Autodesk\CLM\LGS" | Remove-Item -Recurse -Force

Conclusion

While this is a shorter post than my normally long-winded ones, it’s because I don’t think there is much to say here. This made the lives of our Service Desk team much easier and reduced the number of tickets we got during the transition. I hope this helps some other admins going through the same transition. If this was helpful, let me know over on Twitter. I’m on there almost every day and would love to get some feedback as to how it worked for you.

As always, hit me up on Twitter @SeeSmittyIT to let me know what you thought of this post. Thanks for reading!

Smitty

Curtis Smith works in IT with a primary focus on Mobile Device Management, M365 Apps, and Azure AD. He has certifications from CompTIA and Microsoft, and writes as a hobby.

View all posts by Smitty →