Setting an Env: with reference to another env RRS feed

  • Question

  • I am having trouble calling a newly created env: from powershell. 

    $env:sheets = %userprifile%\Sheets

    This should create a variable that reference each users' Sheets folder in their respective user folder.

    When I try to cd env:Sheets I get an error, because PS cannot find the path env:Sheets because it does not exist.

    I am playing with PS because a GPP for the environment variable isn't getting set at all on my computer. Nevermind be able to access that folder's contents.

    Please help me understand what I might be doing wrong or point out my misconceptions with these issues. 

    Monday, March 16, 2015 5:19 PM


  • PowerShell does not recognize percent signs around words, as variable indicators. That said, you can get the user profile path using $env:USERPROFILE. Therefore, you can set your $env:sheets variable as:

    $env:sheets = "$env:USERPROFILE\sheets"

    • Edited by tommymaynard Monday, March 16, 2015 5:32 PM
    • Marked as answer by Jack.Cheney Monday, March 16, 2015 5:45 PM
    Monday, March 16, 2015 5:31 PM

All replies