Windows PowerShell ISE doesn't import PSCX 2.0 module

1

i am using Powershell 2.0 with the PSCX 2.0 module.

When writing PS scripts inside Windows PowerShell ISE no Cmdlets from the PSCX module are availible. For example running "Get-DriveInfo" from Windows PowerShell ISE would cause an error. Running "Get-DriveInfo" from Powershell works fine.

I guess Windows PowerShell ISE doesn't load my PS profile (this would be mad). Does anyone know why and what to do to get it work?

Alexander

Posted 2010-05-12T11:57:34.277

Reputation: 356

Answers

3

I can import pscx 2.0 and execute Get-DriveInfo. ISE has its own profile file, to find its location, type $profile and hit enter (you may have to create it if it doesn't exist):

C:\Users\UserName\Documents\WindowsPowerShell\Microsoft.PowerShellISE_profile.ps1

Shay Levy

Posted 2010-05-12T11:57:34.277

Reputation: 349

How? Can you please elaborate on the steps? I am getting an error on Import-Module pscx (after download and install). – mobibob – 2013-10-23T18:12:20.740

1

Shay's right. And you should note that if you really want your PowerShell profile loaded in your ISE profile, you can just dot-source it by adding this line to the ISE profile:

. C:\Users\UserName\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

There is a good reason why the ISE has its own profile. There are things you can do in the ISE that you cannot do elsewhere (for example, define custom menu items that appear in the ISE). It is useful to be able to do these things automatically at startup using the profile, however you need different profiles to control what is done where.

Also there are things you can do in the Windows PowerShell console that you cannot do in the ISE. For example, you can create a custom prompt in the PowerShell console that displays multiple colors, however the ISE does not support multi-color prompts at this time. This is also something typically done in a profile script.

If you are doing different customizations in different hosts you should set up a script that contains all of the common things you want done in every profile and then dot-source that script into each profile. Then put any host-specific work into the host-specific profiles. For the most part though, unless you're doing some prompt customization or creating add-ons for the ISE, you will only need to deal with your shared script.

Poshoholic

Posted 2010-05-12T11:57:34.277

Reputation: 111