使用传递参数从另一个PowerShell脚本调用一个PowerShell脚本

时间:2013-09-10 18:31:06

标签: powershell

我想从test2.ps1调用test1.ps1。我想在调用时将参数从test2.ps1传递给test1.ps1。

1 个答案:

答案 0 :(得分:4)

PS C:\> gc .\test2.ps1
.\test1.ps1 'foo'
Write-Host 'bar'
PS C:\> gc .\test1.ps1
$a = $ARGS[0] -split ''
[array]::Reverse($a)
Write-Host ($a -join '')
PS C:\> .\test2.ps1
oof
bar