views:

33

answers:

1

Hi,

as far as I understand, powershell has one profile per user. I would like to prepare multiple environments for different "hats" I could put on my head. Like start my "database worker shell" which provides a set of shortcuts for working with special databases. Later I would start an environment which might be my "data processing shell" that provides other shortcuts.

What's the best way to manage that?

cheers, Achim

A: 

I believe there are quite a number of ways and “the best one” depends on many not explained factors. One not best but kind of straightforward way is the following.

Profiles are just scripts automatically dot-sourced in the global scope on start-up. In some sense we can call any script that is dot-sourced in the global scope later “a dynamic profile”. We can have several scripts that install global variables, functions, aliases and etc. with the same names but different values. In other words, we can have several scripts that install different “environments”. At any moment we take one and do:

. Set-Environment<SomeName>.ps1

and continue work with new environment SomeName. More or less, I use the approach like this in practice (exactly when working with databases, BTW).

Roman Kuzmin