0

I am having trouble with this method for launching my powershell script:

PowerShell -NoProfile -ExecutionPolicy Unrestricted -Command "& {Start-Process PowerShell -ArgumentList '-NoProfile -ExecutionPolicy Unrestricted -File ""c:\Program Files\FileMaker\FileMaker Server\Data\Scripts\updateM2.ps1""' -Verb RunAs}";

The above works.. But I would like to pass the parameter to the script...:

UpdateSandP

So where do I put this.. ?

Matt Ayres
  • 33
  • 4
  • Add your parameter arguments to the very end of the `-ArgumentList '...'` string – Mathias R. Jessen Mar 09 '20 at 12:30
  • Does this answer your question? [pwsh -Command is removing quotation marks](https://stackoverflow.com/questions/59036580/pwsh-command-is-removing-quotation-marks) – iRon Mar 09 '20 at 12:33
  • Nope none of the above worked..I tired this and it didnt work: PowerShell -NoProfile -ExecutionPolicy Unrestricted -Command "& {Start-Process PowerShell -ArgumentList '-NoProfile -ExecutionPolicy Unrestricted -File ""c:\Program Files\FileMaker\FileMaker Server\Data\Scripts\updateM2.ps1"" UpdateSandP' -Verb RunAs}"; – Matt Ayres Mar 09 '20 at 12:36
  • Can you show us the `param()` block from `updateM2.ps1`? – Mathias R. Jessen Mar 09 '20 at 12:41
  • Yes I suspect that is the problem?.... #ENTRY POINT Param( [Parameter(Mandatory = $True)] [String] $Update ) – Matt Ayres Mar 09 '20 at 12:42
  • So try adding `-Update UpdateSandP` instead of just `UpdateSandP` :) – Mathias R. Jessen Mar 09 '20 at 12:45
  • Nope doesnt work: PowerShell -NoProfile -ExecutionPolicy Unrestricted -Command "& {Start-Process PowerShell -ArgumentList '-NoProfile -ExecutionPolicy Unrestricted -File ""c:\Program Files\FileMaker\FileMaker Server\Data\Scripts\updateM2.ps1"" -Update UpdateSandP' -Verb RunAs}"; – Matt Ayres Mar 09 '20 at 12:46
  • Does it work at all (without arguments)??? Note my early referral, the command interpreter will strip your double quotes. You will need to escape them with backslashes: ` PowerShell -NoProfile -ExecutionPolicy Unrestricted -Command "& {Start-Process PowerShell -ArgumentList '-NoProfile -ExecutionPolicy Unrestricted -File \""C:\Users\Ronald\OneDrive\Scripts\_Test\PowerShell\Folder with Space\test.ps1\""' -Verb RunAs}" ` – iRon Mar 09 '20 at 13:22
  • Finally got it working with: PowerShell -NoProfile -ExecutionPolicy Unrestricted -Command "& {Start-Process PowerShell -ArgumentList '-NoProfile -ExecutionPolicy Unrestricted -File """"c:\Program Files\FileMaker\FileMaker Server\Data\Scripts\updateM2.ps1"""" """"\UpdateSandP"""" ' -Verb RunAs}"; – Matt Ayres Mar 09 '20 at 13:27

0 Answers0