I\'m trying to pass a parameter to PowerShell from C# web app, but keep getting an error:
Reason = {\"The term \'Param($ds)\\r\\n\\r\\n$ds\\r\\n\\r\\n
Only scriptblocks, ps1/psm1 files and functions/filters can have a param block. The script you should be adding with AddScript should be of the form:
& { param($ds); $ds }
& is the call operator. In your example, you are trying to execute param as a command.
update
You must pass the arguments to the scriptblock like so:
& { param($ds); $ds } 42
This results in 42 being passesd to the scriptblock. Sticking script in with AddScript doesn't implicitly create a ps1 file. It's akin to you typing:
ps c:\> param($ds); $ds
...directly at the prompt; this is meaningless. Make sense?
-Oisin