Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

How to Set a machine level Environment variable in remote machines

$
0
0

Hi,

I have to set a List($ProjectName) as the value of an environment variable($PROJECTS).

The cmdlet which I tried is :

$remoteMachineList = 'machA', 'machB'

$ProjectName = 'ProjA', 'ProjB', 'ProjC'

foreach($remoteMachine in $remoteMachineList){ icm -comp $remoteMachine {
[Environment]::SetEnvironmentVariable("PROJECTS",$ProjectName,"Machine")
}}

This doesn't throw any errors but it's not setting the value of it. If I give a string or an integer value directly instead of the $ProjectName in the above code, it's working fine.

PLease Help, Thanks in advance !




Viewing all articles
Browse latest Browse all 21975

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>