David Salamanca
David Salamanca

Reputation: 11

SSM User does not have access to System Environment Variables

I am using Windows 10 on the servers where we run a .NET application, I need the machines to have environment variables to run a script that call those variables. I used this command as Administrator: [Environment]::SetEnvironmentVariable("MYVARYABLE", "variable_value", [System.EnvironmentVariableTarget]::Machine)

And it was added to the System Variables when I RDP into the Windows Machine and I can run the script that has a reference to $env:MYVARYABLE, I updated the environment using chocolatey refreshenv.

However, when I connect to the Instance using SSM (AWS Systems Manager), I don't longer have access to the environment variables, even though they are set as System Environment Variables.

I want to know why and what would be the best option to run that script from SSM Run Command, or when I connect to the Instance.


UPDATE

When I reboot the Instance from AWS, it has access now to the System Variables on the SSM User, I thought chocolatey refreshenv would do the work but it did not apparently, is there any way I can refresh those variables to be available without the need of restarting the machine?

Upvotes: 1

Views: 258

Answers (1)

Michael Behrens
Michael Behrens

Reputation: 1157

You can configure configurable shell profiles with commands and variables using SSM Session Manager preferences.

For example, you can use these commands by editing the script from the SSM Session Manager Console: enter image description here

And here is the output when tested when connecting via SSM: enter image description here

While I'm using Linux here - you can also enter in Windows commands, to set environment variables, etc.

SET VARIABLE_NAME="Value"

Sorry, I do not have enough time to test out Windows currently.

Upvotes: -1

Related Questions