Need help with PowerShell and Parameters in User Defined Tool Topic is solved

How-to's and other software related queries

Moderator: abstr

Post Reply
OLLI_S
Posts: 30
Joined: Thu Aug 08, 2019 7:23 am

Need help with PowerShell and Parameters in User Defined Tool

Post by OLLI_S » Fri Aug 09, 2019 4:13 pm

Hello,

In ToDoList I have defined a User Defined Tool that calls a PowerShell script:

Code: Select all

Path      : C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Arguments : -noexit -File "C:\MyPath\SendMail_Defizitbewertung.ps1
This works perfectly, the PowerShell script is executed by the User Defined Tool.

Now I wanted to add a parameter (ToDoList should send the title of the selected task as parameter to the PowerShell Script).
For the beginning I started with a static text for testing the parameters.
So I added in ToDoList the following text at the end of the Arguments (the first character is a blank):

Code: Select all

 "OLLI"
In my PowerShell Script I added at the beginning:

Code: Select all

param (
    [String]$ParamAnwendung
)

Write-host "String Parameter: $ParamAnwendung"

pause
When I now test the user defined tool, PowerShell is opening and closing at once (it is not working).
When I remove the parameter "OLLI" again, the the PowerShell is opening and displaying some text (it is working).

I also tried adding the following text at the end of the Arguments (first character is a blank):

Code: Select all

 -ParamAnwendung "OLLI"
But this is also not working.

The strange thing is: when I run the script within a PowerShell console then it works.
Here both of the following ways to add parameters are working:

Code: Select all

C:\MyPath\SendMail_Defizitbewertung.ps1 "OLLI"
C:\MyPath\SendMail_Defizitbewertung.ps1 -ParamAnwendung "OLLI"
In both calls the PowerShell is opening and displaying some text.

Am I doing something wrong?
Or is this a problem with ToDoList?

Best regards

OLLI

OLLI_S
Posts: 30
Joined: Thu Aug 08, 2019 7:23 am

Re: Need help with PowerShell and Parameters in User Defined Tool

Post by OLLI_S » Mon Aug 12, 2019 10:58 am

Hello Daniel,

I found the reason for the problems: I forgot the " at the end of the Arguments.
So instead of:

Code: Select all

Arguments : -noexit -File "C:\MyPath\SendMail_Defizitbewertung.ps1
I should write:

Code: Select all

Arguments : -noexit -File "C:\MyPath\SendMail_Defizitbewertung.ps1"
Now my PowerShell script works perfectly!

Best regards

OLLI

User avatar
abstr
Site Admin
Posts: 370
Joined: Sun Jul 28, 2019 12:22 pm

Re: Need help with PowerShell and Parameters in User Defined Tool

Post by abstr » Fri Aug 16, 2019 8:44 am

That's great news, I'm glad you are making progress. Perhaps you will become our PowerShell expert!

OLLI_S
Posts: 30
Joined: Thu Aug 08, 2019 7:23 am

Re: Need help with PowerShell and Parameters in User Defined Tool

Post by OLLI_S » Fri Aug 16, 2019 9:10 am

abstr wrote:
Fri Aug 16, 2019 8:44 am
That's great news, I'm glad you are making progress. Perhaps you will become our PowerShell expert!
Maybe.....
But it is great what you can do with PowerShell.
You can also create a form an place elements on it...

Post Reply