Wednesday, 18 November 2020

Power Shell Script Send Parameters to .ps1 file from another .ps1 file

 


Step 1: 

Source file , let say     parent.ps1 file contains below code fragment (script line ) to call  child powershell script file let say child1.ps1



& (path)  parameters

& ((Split-Path $MyInvocation.InvocationName)+'\child1.ps1') 'param1'


Information : 
Here & is command executable statement.
Here path is the path of child1.ps1 file
Here parameters are parameters which you would pass to child1.ps1 powershell script file



Read the parameters from child1.ps1 power shell script file 
Below are the script to read the parameter into power shell script 

$parValue = $args[0]
Write-Host $parValue










No comments:

Post a Comment