user2034859
user2034859

Reputation: 637

How to set a variable in powershell then get variable from cmd

I'm executing a powershell script from cmd window. Within the powershell script I want to set a variable that later can be reached from cmd window, once the ps script has finsihed. How do I do that?

I have tried:
PS promt: Set-Variable -Name "MyParameter" -Value "MyParameter1234" -Scope Global -Visibility Public CMD promt: set MyParameter

Please help me figure this out.

Upvotes: 1

Views: 301

Answers (1)

Gaterde
Gaterde

Reputation: 819

Easiest way would be to write the variable to a file, close the Powershell window, read the file in the cmd window and put it in to a variable and then delete the file.

Upvotes: 1

Related Questions