I am Trying To add a System Variable here using PowerShell:
I have tried both ways using
$env:MyTestVariable = \"My test variable.\"
Run PowerShell as an administrator (to get the necessary registry access permissions) then call out to the .Net framework to set it:
[Environment]::SetEnvironmentVariable("MyTestVariable", "MyTestValue", "Machine")
NB. it won't take effect within the same process, you'll have to make a new PowerShell process to see it.