How to pass a string from Powershell script to the batch file which calls it?

My batch file calls a Powershell script, which creates a file whose location (path & name) it saves in a variable $outputfile. E.g. $outputfile = "C:\Test\History\myfile.csv".

How can I easily pass the value of $outputfile back to the batch file which calls the Powershell script. I cannot know the value of $outputfile before running the Powershell script. (In the calling batch file I want to run commands on the file represented by $outputfile.)

One idea is to save $outputfile to an environment variable in the called Powershell script, then read this in the calling batch file.

Is there an easy way to pass the the value of $outputfile? Not knowing much about the life of environment variables, I wonder if this is a good way to do this, or if there are easier ways.



from Recent Questions - Stack Overflow https://ift.tt/NY1XoLe
https://ift.tt/4ajfIVs

Comments

Popular posts from this blog

Spring Elasticsearch Operations

Network Error and Timeout on Authorize.net JS

Object oriented programming concepts (OOPs)