Thursday, 17 April 2014

How to call and pass parameter from one PowerShell script file to another?

I came across a scenario where I have to call another PowerShell script file and pass the current PowerShell script file input parameter to this second file.

PowerShell as the name says is very powerful and I was able to achieve my requirement with a simple expression called as "Invoke-Expression" in PowerShell.

Just to explain you how I have achieved my above requirement, I have created two demo PowerShell files called First.ps1 and Second.ps1. I am gonna show you how I have called First.ps1 and invoke the Second.ps1and pass the First.ps1 input parameter to the Second.ps1 with "Invoke-Expression".

Hope this is helpful.
Isha Jain

No comments:

Post a Comment