adding powershell console window inside a form

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
rslaav
Posts: 14
Joined: Mon Jun 08, 2020 2:01 pm

adding powershell console window inside a form

Post by rslaav »

Product, version and build: powershell studio 2020
32 or 64 bit version of product: 64bit
Operating system: windows 10 pro
32 or 64 bit OS: 64bit

hi folks, quick question regarding forms, as I relatively new to programming with scripting languages (apart from python—which is interpreted, but way more than a scripting language). Does powershell studio introduce anything new that would permit me to include a powershell terminal session inside my windows form using powershell scripting only on my end?

Essentially, I imagine the Powershell ISE application, it's pretty much what I want to accomplish, but with less features. I want a form that includes 3 elements: a textbox for reading stuff like plain-text (details irrelevant), a powershell command line interface right bellow her, and an ok button for laughs. Is this possible? If so how? It doesn't have to be powershell only, if I have to call some c# that might be ok too. :)

rslaav
Posts: 14
Joined: Mon Jun 08, 2020 2:01 pm

Re: adding powershell console window inside a form

Post by rslaav »

just an fyi, i am not trying to create a ListBox that receives the ouput of a cmdlet, etc. https://docs.microsoft.com/en-us/dotnet ... lsdk-7.0.0

I am trying to get an actual or equivalent powershell command line in a windows form, like the one in ISE. We should be able to create our own version of ISE, i'd hope. :)

User avatar
Alexander Riedel
Posts: 7407
Joined: Tue May 29, 2007 4:43 pm

Re: adding powershell console window inside a form

Post by Alexander Riedel »

See https://github.com/PowerShell/PowerShell/issues/9175
Basically that would require Microsoft to open source at least parts of the ISE, which they won't.
You can also attach a console process to the Windows Forms process and use the Windows console API to 'reflect' that console into a window.
Or you can simply create your own windowed console. The 'simply' here is a little tongue in cheek.
It would require quite some system level coding in C# or preferably C++ to do exactly what you ask and is way beyond the scope of using PowerShell.

You could however combine a multi-line richtext control (for the easier access to coloring) with a single line textbox control. The
textbox would provide a means for input, the prompt so to speak, and the multi-line control would be the means to see the output.
Alexander Riedel
SAPIEN Technologies, Inc.

rslaav
Posts: 14
Joined: Mon Jun 08, 2020 2:01 pm

Re: adding powershell console window inside a form

Post by rslaav »

bloody microsoft :(

Locked