0

I want a script to get a variable from a different script which are both running on the system. Is that possible?

I have two scripts running on the system, and I want one script to pull a user-defined variable instead of asking the user to input the data twice

Falah Abu Hassan
  • 105
  • 2
  • 11
  • Here is another stackoverflow post that may answer your question: [Global Variables](http://stackoverflow.com/questions/12535419/powershell-setting-a-global-variable-from-a-function-where-the-global-variable-n) – Raged Mar 27 '14 at 15:36

2 Answers2

0

Assuming both scripts are running concurrently, MSMQ would be one option:

What's the best way to pass values to a running/background script block?

Global Variables are only "Global" in the context of scopes in the current session. They aren't visible to a script running is a different session.

Community
  • 1
  • 1
mjolinor
  • 66,130
  • 7
  • 114
  • 135
0

Write it to a text file and have the other script read it. You can load up the text into a variable, then execute it as code using iex (Invoke-Expression).