Search code examples
powershellpowershell-remotingnano-server

Setting machine wide environment variable in Nano server


I started a remote session from VM host(desktop) to the guest VM having a Nano server(preview 5). I would like to update the PATH variable and make it effect machine wide(example: to put dotnet.exe in PATH to enable running portable apps). What I am noticing is that the SetEnvironmentVariable overload doesn't have the overload which takes in the target(like 'User', 'Machine' etc.).

If you notice I have the overload in my host's Powershell (the version is a bit older than the Nano server one) but not on the Nano server's one.

In my Nano server: enter image description here

In my VM host(desktop) enter image description here

What am I missing?


Solution

  • This is due to the fact that Nano server uses a stripped down version of .NET called .NET Core. (More info on MSDN.)

    The documentation for the Core implementation of SetEnvironmentVariable is available here.

    EDIT 26 Sept 2017:

    This answer applied to .NET Core 1.x. In .NET Core 2.0, the overload the OP was looking for has been added. The documentation for 2.0 is here.