Launch PowerShell as an administrator (to obtain the necessary permissions to access the registry), then call the .Net infrastructure to install it:
[Environment]::SetEnvironmentVariable("MyTestVariable", "MyTestValue", "Machine")
NB. , PowerShell, .