How to set Windows environment variables for 100 shops

Hello,

We have 100 shops.
I need to set a Windows environment variable to every shop:
shop 1: shopcode=‘A001’,
shop 2: shopcode=‘A002’,
… … …
shop 100: shopcode=‘A100’

Of course I can do the task one by one manually through Remote Desktop or VNC, however, I still want to know can I use Powershell to do that?

  1. Create a text file of all the 100 shops’ codes.
  2. Send my generic script file to the 100 shops, eg. through FTP by checking against the shop list
  3. Or send my 100 script files (with different shopcodes) of making new environment variable to the 100 shops.
  4. Do you understand what I mean?
  5. Can Powershell do all the above steps in one scheduled task?
  6. Or they are out of the scope of Powershell?

Any idea?
Could you help me?

Yes. What you’ve described can be done in PowerShell. You probably don’t need FTP and a scheduled task if you can use PowerShell Remoting.

Invoke-Command -ComputerName NodeShopA001 -ScriptBlock { ... }

Setting the machine environment variable can be done with below statement in PowerShell which can be embedded a scriptblock being executed on the designated machine:

[System.Environment]::SetEnvironmentVariable('shopcode', 'A001', 'Machine')