How to set environment variables in Server Core?

Use setx thus:

setx is built into cmd.exe. It can be used to make changes to a remote computer too.

setx modifies the “persistent” store though, not the “active” store (to borrow a terminology from netsh. What this means is that the changes by setx only take place when you open a new command prompt, it doesn’t affect the existing one.