Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Question about running another script with an argument

$
0
0

Hi,

I need to run ps1 file with arguments from a main script.

let's say i have this script - simple function that writes to screen according to the input parameter from the main script :

------------------------------

function test($global:param1) {

write-host $param1

Start-Sleep 3

}

test($param1)

----------------------------

Main script is something like that:

$global:param1="this is a test"

$arglist = "C:\PS_tests\fucntionTest.ps1", "$param1"  

Start-Process powershell.exe -ArgumentList $arglist 

It does run the function and i can see the 3 seconds delay but the parameter param1 is not in used by the function. Any suggestions how to make it work?

Daniel


Viewing all articles
Browse latest Browse all 6937

Trending Articles