powershell get current users path variable

Welcome Forums General PowerShell Q&A powershell get current users path variable

Viewing 2 reply threads
  • Author
    Posts
    • #195875
      Participant
      Topics: 3
      Replies: 11
      Points: 55
      Rank: Member

      Hi

      How I do get the PATH value only for a single user ?

      I have two user on my desktop and I want to change the PATH only for the ‘User1’

      for example :

      $PATH = $env:Path
      $PATH += “;” + $jdkInstallFolder +”\bin”    #The new folder to add
      Set-EnvironmentVariable -name PATH -Value $PATH -Target User
      But it doesn’t work because It’s adding the path of the whole machine to single user Path ( User1)
      so I get a double string.
      I’m very confused
      Can you help me , thanks !
    • #195887
      Participant
      Topics: 7
      Replies: 2458
      Points: 6,439
      Helping Hand
      Rank: Community MVP

      As far as I know Set-EnvironmentVariable is not a built-in cmdlet of Powershell. So you might ask the author of that function to help you.

      You could use a dotNet method to achieve what you’re looking for How To Work with Environment Variables in PowerShell

    • #195893
      Participant
      Topics: 3
      Replies: 11
      Points: 55
      Rank: Member

      Olaf ! Thanks ! I’ve searched on google , but I didn’t find that article

      Solved !

Viewing 2 reply threads
  • The topic ‘powershell get current users path variable’ is closed to new replies.