$Env:<variable-name> = "<new-value>"
实例如下
$Env:test = "test"
然后执行
Get-ChildItem Env:
看到你设置的环境变量 表示设置成功
参考文章: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_environment_variables?view=powershell-6