Works in ISE but not Console

Welcome Forums General PowerShell Q&A Works in ISE but not Console

This topic contains 2 replies, has 1 voice, and was last updated by

1 year, 9 months ago.

  • Author
  • #72133

    Points: 0
    Rank: Member

    I found this answer on

    Script not work on console

    Is there any chance I can trial and error my way through what's being called to see if I can isolate the problem?
    If so, any recommendations on how I might go about that?

    These are my commands:



    Add-Type -AssemblyName PresentationCore,PresentationFramework
    $Window = [System.Windows.Window]::IsActiveProperty
    $ButtonType = [System.Windows.MessageBoxButton]::OK
    $MessageIcon = [System.Windows.MessageBoxImage]::Error

    $Result = [System.Windows.MessageBox]::Show($MessageBody,$MessageTitle,$ButtonType,$MessageIcon)

    IF there are other parameters that may affect launching in console I'd love to know.


  • #72140

    Points: 0
    Rank: Member

    Actually, I can get the GUI to remain open but I have to use powershell.exe -noexit -File blah

    Without the noexit, the GUI shows for a fraction of a second just as the console window is disappearing.

    BTW, I'm not using any taskbar notices. It's just a GUI window with two buttons, a list box and a textbox.



  • #72146

    Points: 0
    Rank: Member

    Ok, I got it to work correctly...

    with a batch script (ugh).

    powershell.exe -noexit -windowstyle hidden .\foo.ps1

    You know I've been running a lot of powershell scripts using batch files with these switches but always after -File blah.

    Turns out powershell assumes you are running the switch against the file.

    Move the switches to just after powershell.exe and they behave as they should.

    So What I get is
    The console window appears briefly, disappears, then the gui window pops up a few moments later

    All the functions work.

    I have another post on here that wasn't completed asking how to run a series of commands after a one button click. I found that answer so I will resurrect that post to answer it.

The topic ‘Works in ISE but not Console’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort