Purpose
The purpose of this article is to explain how to set the license for PowerShell Universal by way of environment variable instead of the traditional file-based method.
Scope
For now, only Windows is in the scope of this article. Linux and MacOs will be added in the near future.
Background
This approach can be desirable in certain scenarios (e.g. Azure DevOps pipelines).
Procedure
1. If there is an instance of PowerShell Universal already installed, remove its license from the console (or Remove-PSULicense) and then stop the instance service.
2. Set the environment variable (at the machine level) to PSULICENSE as the entire content of your license data. It should start with the < character per image below. There are a number of ways to set the environment variable.
3. At this point I would actually restart the system just to be safe.
4. If stopped, start the PowerShell Universal instance and logon to confirm the license status.
Verification
For logged confirmation that the procedure is working, set the logging to Debug level and restart the PowerShell Universal instance. Observe the log entry in below image: "Loading license information."