transcript from winform script

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 8 years and 1 month 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
User avatar
LtMandella
Posts: 61
Last visit: Mon May 07, 2018 4:03 pm

transcript from winform script

Post by LtMandella »

Product, version and build:studio 2015
32 or 64 bit version of product:64 bit
Operating system: win server 2008 r2
32 or 64 bit OS: 64

I am not having any luck getting a transcript in a wonforms script to work as expected.

Is there a recommended way to get a transcript type log from a winform script? I don't expect to see a transcript of all the users interactive winform activity, but I'd like to get a complete transcript of all the powershell script execution up to the moment the winform opens.

I have written scripts completely by hand that run winforms and in those start-transcript outputs a very useful and verbose transcript.

thanks,
ken
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: transcript from winform script

Post by davidc »

[POST MOVED TO POWERSHELL GUI FORUM BY MODERATOR]
David
SAPIEN Technologies, Inc.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: transcript from winform script

Post by jvierra »

What is it that is not working? Did you specify the complete path to the transcript file?
User avatar
LtMandella
Posts: 61
Last visit: Mon May 07, 2018 4:03 pm

Re: transcript from winform script

Post by LtMandella »

Hi jvierra,

Here is what I am doing to get this to work. Probably I am doing it all wrong and there is a better way

I want to audit ALL possible errors and a numerous object properties, arbitrary text from output inside the functional script, etc. So my usual practice is to always call my "functional" script from a parent "logging" script.

Basically the "parent" script will always look like this:
---------------------------------------------------------
Start transcript -path c:\blah\auditfilename.txt

Invoke-Expression "\\somepath\somefunctionalscript.ps1 `'$inputList`' `'$CommaListParams`'"

Stop-Transcript
--------------------------------------------------------------

This way even if the functional script won't compile/execute, I still capture and persist useful info about the problem.

To make this work with a winform script, I have to hack the .psf file after export of the .ps1 and remove the "Out-Null" from the call to the .psf at the end of the generated .ps1 export file.

Is there a better way?

thank you!
Ken

p.s. pshell studio 2015 is one of the best tools I have ever used (in a long career)...
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: transcript from winform script

Post by jvierra »

Why? Why don't you just add the Start-Transcript to the body of the form file and run it?
-
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: transcript from winform script

Post by jvierra »

Ok - I see it. IK have always been unfavorable about this technique for launching a script. Maybe now we can get it fixed.

Not sure about this. Maybe the guys at Sapien can come up with a fix. I will flag them. Meanwhile can you post your issue to the Customer Service forum?
User avatar
LtMandella
Posts: 61
Last visit: Mon May 07, 2018 4:03 pm

Re: transcript from winform script

Post by LtMandella »

Thanks for the reply, I will post in customer service (although was it moved from there one time already?)

[[ I have always been unfavorable about this technique for launching a script]]

If you get a moment, could you recommend alternative?

thanks again,
ken
User avatar
Alexander Riedel
Posts: 8488
Last visit: Tue Apr 16, 2024 8:42 am
Answers: 20
Been upvoted: 37 times

Re: transcript from winform script

Post by Alexander Riedel »

FYI, the customer service forum is not the correct place for product support.
The "Customer Service" forum is for non-product specific questions, e.g. your SAPIEN account.
The appropriate place is the forum for the specific product, in this case the "PowerShell Studio" forum.
viewforum.php?f=12
Alexander Riedel
SAPIEN Technologies, Inc.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: transcript from winform script

Post by jvierra »

LtMandella wrote:Thanks for the reply, I will post in customer service (although was it moved from there one time already?)

[[ I have always been unfavorable about this technique for launching a script]]

If you get a moment, could you recommend alternative?

thanks again,
ken
Right now your workaround is the only one. Perhaps the programmers at Sapien can add an option to not use Out-Null. With Out-Null all output is tossed and does not get sent to the transcript engine. This is due to running a medal form which delays all output.

In many forms we like to grab the form object. It has long been my feeling that returning th form object on DialogResult::OK is more useful. This would alos preclude the need for Out-Null.
if($form.ShowDialog() -eq 'Ok'){ %form}

To detect result we can just:
  1. if($frm=Call-MyForm_psf){
  2.     #process $frm - $frm contains all data
  3. }
I suspect this would have to be an option as so many scripts are designed on the current method.

Another workaround would be to generate a script file and run it in the CLI of PowerShell. It is still multi-step but does not require the manual edit.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: transcript from winform script

Post by jvierra »

Alexander Riedel wrote:FYI, the customer service forum is not the correct place for product support.
The "Customer Service" forum is for non-product specific questions, e.g. your SAPIEN account.
The appropriate place is the forum for the specific product, in this case the "PowerShell Studio" forum.
viewforum.php?f=12
Sorry - I typed without thinking.
This topic is 8 years and 1 month 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