Varun Gupta
Varun Gupta

Reputation: 1457

Invoke one PowerShell script from Another PowerShell script with passing arguments

I want to invoke test1.ps1 from test2.ps1. And I want to pass arguments from test2.ps1 to test1.ps1 while invoking.

Upvotes: 0

Views: 2178

Answers (1)

Ansgar Wiechers
Ansgar Wiechers

Reputation: 200273

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

Upvotes: 4

Related Questions