How to pass a parameter from Batch file to a function inside a Powershell script

Question:

I have a Batch file which will call a Powershell Script :

BATCH FILE :
@ECHO OFF
powershell ..\PowerShellScript.ps1

The powershell script in turn has a function which expects a parameter :

POWERSHELL SCRIPT:

Lets say i have a value : VALUE1 which needs to be passed from the batch File while calling the PowerShellScript.ps1, how do I pass it to the function PSFunction so that my output is VALUE1?

Answer:

modify your script to look like the following

and from the batch file, it would look like

Source:

How to pass a parameter from Batch file to a function inside a Powershell script by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply