tags:

views:

91

answers:

2

I am trying to call a script that gives data as a parameter for another script.

ex.

scriptA.ps1 -parameter1 (scriptB.ps1 -data 'testOne')

I just put () because I thought that would work but can't seem to get it to work. Any ideas? I have tried $() and "" to no avail.

Thanks.

+2  A: 

If you want to pass scriptB.ps1 as a scriptblock, then use

./scriptA.ps1 -parameter1 {./scriptB.ps1}

If you want to pass the output of scriptB.ps1 as a type (i.e - assuming scriptB outputs a type), then use

./scriptA.ps1 -parameter1 (./scriptB.ps1)
thedugas
Using @Keith Hill's input, I removed the call operator and the "$" from the parameter1 arguments.
thedugas
+4  A: 

In this case, you most likely have scriptb.ps1 in the same dir as scripta.ps1. PowerShell does not run scripts in the same dir without explicitly specifying the path (either absolute or relative path). The following is sufficient to make this work:

.\scripta.ps1 -parameter1 (.\scriptB.ps1 -data 'testOne')
Keith Hill
@Keith Hill - you are absolutely right, and I edited my answer to remove the "$" and call operator from the parameter1 argument to reflect.
thedugas
No problem. PowerShell is a surprisingly deep well. I still learn new stuff about PowerShell and I've been a PowerShell MVP since 2006. :-)
Keith Hill