Page 1 of 1

Save Date in variable after executed script

Posted: Thu Jan 10, 2019 9:54 pm
by ALD Automotive
Product: PowerShell Studio 2019 (64 Bit)
Build: v5.6.156
OS: Windows 10 Enterprise (64 Bit)
Build: v10.0.14393.0

Hello,
Could you please let me know, is it possible save data inside variable after script executed (as simple Powershell).
For example i get in $data information from file and folders with big time executed. ( $data= ls \\server\sharefolder -recurcive ... ). I waste 15 min to collect $data and my next step working with this data (modify, copy, rename e.t.s.).
Question: How to save $data info? I don't want collect $data any time.

Re: Save Date in variable after executed script

Posted: Thu Jan 10, 2019 10:12 pm
by Alexander Riedel
I am not sure if that is a general "How to do this in PowerShell" question or a specific PowerShell Studio question.
For the latter, If you have a script where you need to examine variables *after* the script terminates to verify things, simply use "run in console".
You can then examine any variable your script created or modified. Be mindful though that repeated runs in the same console will not produce reliable results.
If this is a general question, save the content of your variable to a file and load it when executing it again. Only if the file does not already exists (or needs to be refreshed) you run your lengthy operation. But I would submit that files on a server probably change all the time :D