Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

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

share|improve this answer
    
How? Can you please elaborate on the steps? I am getting an error on Import-Module pscx (after download and install). –  mobibob Oct 23 '13 at 18:12

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.