How to set Windows environment variables for 100 shops

This topic contains 1 reply, has 2 voices, and was last updated by Profile photo of Daniel Krebs Daniel Krebs 3 months, 3 weeks ago.

  • Author
    Posts
  • #63447
    Profile photo of molo
    molo
    Participant

    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?

  • #63451
    Profile photo of Daniel Krebs
    Daniel Krebs
    Moderator

    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')
    

You must be logged in to reply to this topic.