get output of a ps1

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 4 years and 4 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
klarlichter
Posts: 40
Last visit: Sun Jan 16, 2022 3:44 am

get output of a ps1

Post by klarlichter »

Hello,

i create action on button click: Invoke-CertExServer16_ps1
i also place there a function to open another form: Show-outputPS1Box_psf

togehter it looks like:

Code: Select all

$buttonZertifikatErzeugen_Click={
	#TODO: Place custom script here
	#run CertExtServer16.ps1 script
	Invoke-CertExServer16_ps1
	Show-outputPS1Box_psf
}
How it is possible to show the output of invoke action on show-outputPS1Box_psf?

Hope someone can help.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: get output of a ps1

Post by jvierra »

You will have to capture the output and pass it as a parameter to the "show" script.
klarlichter
Posts: 40
Last visit: Sun Jan 16, 2022 3:44 am

Re: get output of a ps1

Post by klarlichter »

How i can caputre that? and how to pass it?

Caputre not working like:

Code: Select all

$mycommand = Invoke-CertExServer16_ps1 | Out-String
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: get output of a ps1

Post by jvierra »

Without some basic understanding of how to use PowerShell all of this will be very difficult for you.

Here is a free book that will give you the background that you need to use PowerShell with PowerShell Studio.
https://www.sapien.com/books_training/W ... werShell-4

You can also find answers and examples here: https://info.sapien.com/index.php/guis

The left menu contains many resources for learning how to use PSS and Forms.

There are many videos here that can help you with PowerShell, PowerShell Studio and Forms: https://www.youtube.com/c/SAPIENTech
klarlichter
Posts: 40
Last visit: Sun Jan 16, 2022 3:44 am

Re: get output of a ps1

Post by klarlichter »

Hello,
i am proud to get some code working and i willing to lern and also review your sources.
But is it possible that you can post a example how i can pass that?
I mean how to caputre and show? It would be amazing.
klarlichter
Posts: 40
Last visit: Sun Jan 16, 2022 3:44 am

Re: get output of a ps1

Post by klarlichter »

If i let run my example

$textbox1.Text = ipconfig /all | Out-String
I see that output inside textbox

If I let run $textbox1.Text = Invoke-CertExServer16_ps1 | Out-String i cant see that output ... i only can see inde debug output inside of powershell studio the output :(
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: get output of a ps1

Post by jvierra »

You cannot send output from a form. You must access one of the provided variables that contain the data from the form.

Again. Their are articles in the info center that describe ow to use this in detail with examples. Learning how to use the info center will provide you with and excellent resource while learning PowerShell and PowerShell Studio,
klarlichter
Posts: 40
Last visit: Sun Jan 16, 2022 3:44 am

Re: get output of a ps1

Post by klarlichter »

Hello,

if i try that

example1:

Code: Select all

$buttonZertifikatErzeugen_Click={
	#TODO: Place custom script here
	$textbox1.Text = Invoke-CertExServer16_ps1 $contactEmail.Text $pfxPassword.Text | Out-String
}
It should normally display that output below on my textbox. (after press that button)

But it not display any. I try with simple command:

example2:

Code: Select all

$buttonZertifikatErzeugen_Click={
	#TODO: Place custom script here
$textbox1.Text = ipconfig /all | Out-String
}
and thats working. Wht it is only working with example 2 and not with example 1?

It might be happen because on example 1 i exectute a script from prject and on example 2 i exectute a command direct? Is that right?
If yes how i can get that output about that script who i exectute from that project folder?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: get output of a ps1

Post by jvierra »

klarlichter wrote: Sun Nov 24, 2019 2:55 pm
and thats working. Wht it is only working with example 2 and not with example 1?
As I noted - you cannot output from a form to anything. It is not possible. You must transfer data from a form through a variable.

Please see the blog posts and articles on passing values between forms. They are listed on the left menu in the info center.
klarlichter
Posts: 40
Last visit: Sun Jan 16, 2022 3:44 am

Re: get output of a ps1

Post by klarlichter »

Hi, i think now we get a miss - understanding.

How I pass a variable from one to another form i understood now. :)

As you can see my example 2 working as I told.

My example 1 not working.
You want to tell that i need save the output of my PS1 script into a variable and then pass them back to form? Is it right?
This topic is 4 years and 4 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked