Powershell: Passing parameter of output script
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 ide开发者_如何转开发as? I have tried $() and "" to no avail.
Thanks.
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')
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)
精彩评论