0

I'm trying to pass a parameter to my application like (filename.exe -Param Value) but no luck.

I'm trying to capture the parameter with this

Param([Parameter(Mandatory=$true)][string]$message)
write-host $message

Using the command line to execute the compiled script I try to pass in the parameter but it wont work, below is an example. I've also tried with --message, /message nothing works.

C:\Users\OptiPlex\Desktop>Read_Host_Secure_String.exe -message Hello
cmdlet Read_Host_Secure_String.ps1 at command pipeline position 1
Supply values for the following parameters:
message:

Image

StevenGDC
  • 1
  • 1
  • thanks for the input, I did indeed, but that´s no the problem unfortunately. – StevenGDC Oct 08 '22 at 23:59
  • You're invoking an `.exe` file, but the prompt is being put up by a `.ps1` file. Without knowing how the former calls the latter, it's hard to diagnose your problem. – mklement0 Oct 09 '22 at 00:01
  • The .exe is compiled by PowerGUI Script Editor, I won´t know how it compiles the ps1... – StevenGDC Oct 09 '22 at 00:06
  • I'm not familiar with PowerGUI, but it seems that at least with the particular `.exe` you've created pass-through arguments are either unsupported or - perhaps, I don't know - require special syntax. – mklement0 Oct 09 '22 at 00:07
  • yeah, will be one of the two, hopefully someone can confirm it, I´m hoping for the latter .. – StevenGDC Oct 09 '22 at 00:09
  • Best asking on PowerGUI forums. It could well be that parameneters have to be passed in a soemhting like `-Param` switch rather than using the original variable – Scepticalist Oct 09 '22 at 17:38

0 Answers0