Leland DeBord
Leland DeBord

Reputation: 1

Batch file call powershell pass variable to smtp $message

I have a batch file that is menu driven. Users answer two questions. Based on their answers 2 variables are created and files are transferred. After that, my batch file calls a powershell script to email me. I need to find a way to put the 2 variables from the batch file into the $message = section of the powershell script. Any assistance would be greatly appreciated.

Upvotes: 0

Views: 869

Answers (1)

Keith Hill
Keith Hill

Reputation: 202052

If you are setting environment variables, you can reference those in a PowerShell script spawned from the same cmd.exe environment like so:

$message = "this is your $env:test and you are $env:test2"

Upvotes: 1

Related Questions