I found this answer on Powershell.org:
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.
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.
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.