Is it possible to start Powershell ISE with specified (not default) profile?

5.7k views Asked by At

I want to have several (more than one) PowerShell profiles which will create different environments.

More specifically I need way for start separate PowerShell ISE for work with TFS and other PowerShell ISE instance for regular work. 'TFS' environment require loading some additional snappins, modules, modify prompt and so on. I do not want all this stuff will be executed for regular PowerShell ISE sessions but only when I want to.

I found that I can automatically load arbitrary script through command line parameter -File, but it does not executed automatically..

2

There are 2 answers

5
JPBlanc On BEST ANSWER

I do it by creating a shortcut for PowerShell ISE with a default directory :

ISE PowerShell ShortCut here

In the default Directory (here called D:\TFS) I create a .PS1 file called local_profile.ps1.

In the beginning of the current profile file (C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1) I add :

# Try to load local profile
Get-ChildItem "local_profile.ps1" -ErrorAction SilentlyContinue | %{.$_}

You just have to add your initialization code to D:\TFS\local_profile.ps1.

1
wallybh On

powershell ISE has a profile too.

Probably is something like: E:\Users\UserName\Documents\WindowsPowerShell\Microsoft.PowerShellISE_profile.ps1

Or you can open powershell ise and look at $profile variable.

After locate your profile file, write your modules import and custom scripts in it.