1

I've found that the $HOME variable can be rather useful for keyboard-only navigation in PowerShell. It would be nice to have a number of shortcuts stored as persistent path variables that can be accessed using the same syntax. I've seen the method $env:MyTestVariable = "My temporary test variable." but the result isn't persistent and still has to be accessed by typing $env:MyTestVariable which is not as succinct as the desired $MyTestVariable.

How can I create such variables and control what level has access to them (aka User, Machine, and Process)?

mklement0
  • 382,024
  • 64
  • 607
  • 775
Shadow43375
  • 514
  • 7
  • 20
  • 4
    You can define those variables in your profiles. Either in AllUsersAllHosts, AllUsersCurrentHost, CurrentUserAllHosts or CurrentUserCurrentHost. ;-) – Olaf Aug 17 '20 at 01:21
  • https://stackoverflow.com/a/2571200/5298150 – abdusco Aug 17 '20 at 02:44
  • Does this answer your question? [Setting Windows PowerShell environment variables](https://stackoverflow.com/questions/714877/setting-windows-powershell-environment-variables) – Compo Aug 17 '20 at 02:56
  • That question asks about "setting" enviroment variables which may, or may not, be identical to the procedure of creating *new* ones. Additionally, it doesn't explicitly address the specifics of my post regarding the verbosity of $env:MyTestVariable as opposed to $MyTestVariable. In short-- while it may be possible to deduce the answer to my question from that post it is not identical. – Shadow43375 Aug 17 '20 at 13:07

0 Answers0