Setting a persistent environment variable
If you want to set a variable but you want it to live forever then you can use
[System.Environment]::SetEnvironmentVariable("JAVA_HOME", "c:\program files\openjdk\jdk-13.0.2", "Machine")
That last argument can take on the values {Process
, User
, Machine
}