Differences between the ISE and PowerShell console

Differences between the ISE and PowerShell console

  • Comments 3

Here is a collection of differences between the PowerShell_ise.exe and PowerShell.exe, as well as workarounds
and suggestion if you need them (assuming we have them :))

  1. Limited support for interactive console apps, try cmd.exe, then try cmd.exe /k
    1. cmd.exe /c dir still works though, and more information is available here
      http://blogs.msdn.com/powershell/archive/2009/02/04/console-application-non-support-in-the-ise.aspx
  2. Console Application output is not colorful
  3. STA by default
    1. Try $host.Runspace.ApartmentState
    2. powershell is MTA by default (ApartmentState shows up as Unknown) but can be started in sta mode with powershell -sta.
    3. ISE is always STA
  4. No support for the [Console] class, try [console]::BackgroundColor  = 'white'.
    1. In general, scripts should use the host API's (write-host, instead of the [Console] class, so that they work in both the console, ISE, Remoting and other shells.
  5. Limited (close to zero) support on $host.UI.RawUI. We only support the colors and title
    1. The colors are better set in $psISE.Options, because you can set those to any color, not just console colors
  6. Custom/dead-simple more. See gc function:more
    1. The ISE has no pager
  7. Start-Transcript does not work in the ISE
  8. Some Thread Culture differences
    1. If you’re in a non-console supported culture (eg Arabic) ISE will have Get-Culture as ar-sa, and powershell.exe will have Get-Culture as en-us (or some other fallback)
  9. Suggestions dont work in the ISE
    1. For example, in C:\Program Files\Internet Explorer" if you execute iexplore.exe
    2. You'll only see this in PowerShell.exe
      Suggestion [3,General]: The command iexplore.exe was not found, but does exist in the current location. Windows PowerShe
      ll doesn't load commands from the current location by default. If you trust this command, instead type ".\iexplore.exe".
       See "get-help about_Command_Precedence" for more details.
  10. The ISE runs a different profile
    1. The ISE profile is in Microsoft.PowerShellISE_profile.ps1, and powershell is in Microsoft.PowerShell_profile.ps1
    2. http://msdn.microsoft.com/en-us/library/bb613488(VS.85).aspx
    3. http://www.leeholmes.com/blog/TheStoryBehindTheNamingAndLocationOfPowerShellProfiles.aspx
    4. You can use the common profile, stored in $profile.CurrentUserAllHosts to make it run in both shells
  11. Only the ISE has $psISE
    1. it gets access to http://psisecream.codeplex.com/, and http://blogs.msdn.com/powershell/archive/2008/12/29/powershell-ise-can-do-a-lot-more-than-you-think.aspx

There could be others, but parity with PowerShell is a big thing for the ISE.

Cheers,
Ibrahim Abdul Rahim
[MSFT]

Leave a Comment
  • Please add 8 and 6 and type the answer here:
  • Post
  • PingBack from http://microsoft-sharepoint.simplynetdev.com/differences-between-the-ise-and-powershell-console/

  • Function GLOBAL:Screen {

    Param ($Screen, $Colour)

    $Pane = $Null

    Switch ($Screen)

    {

    S { $Pane = 'ScriptPaneBackgroundColor' }

    C { $Pane = 'CommandPaneBackgroundColor' }

    O { $Pane = 'OutputPaneBackgroundColor' }

    H { $Pane = 'OutputPaneTextBackgroundColor' }

    F { $Pane = 'OutputPaneForegroundColor' }

    }

    $Pane

    $PSIse.Options.$Pane = $Colour

    $PSIse.Options

    }

    If ($PSIse) {

    $Q = Read-Host "Am I going Blue ? "

    If ($Q -eq "Y") {

    Say Going Blue

    Screen S '#CCFFCC' # Light Blue

    Screen C '#CCFFFF' # Lighter Blue

    Screen O '#66CCFF' # Powder Blue

    Screen F '#000000'

    Screen H '#66CCFF'

    }

    Else {

    Say OK Back to White

    Screen S '#FFFFFF'

    Screen C '#FFFFFF'

    Screen O '#FFFFFF'

    Screen F '#000000'

    Screen H '#FFFFFF'

    }

    }

  • Hey folks,

    I have a powershell script that is waiting on a crash event from the event log using register-objectevent. It works fine in PowershellISE however it doesn't in powershell.exe. What gives? I tried a few of these supsect powershell.exe command line switches to no avail. Here's my script:

    $eventlog = new-object System.Diagnostics.EventLog

    $eventlog.Log = "Application"

    $subscription = Register-ObjectEvent -InputObject $eventlog -EventName EntryWritten -Action { HandleCrash $EventArgs }

    Function HandleCrash($EntryWrittenArgs)

    {

       if($EntryWrittenArgs.Entry.InstanceId -ne 1001)

       {

           return

       }

       if(-not ($EntryWrittenArgs.Entry.Message -match "P1:\s+.*"))

       {

           return

       }

    ...More stuff...

    This definitely WORKS in powershell ISE. You can imagine my frustration here :-).

Page 1 of 1 (3 items)