Save Date in variable after executed script

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
User avatar
ALD Automotive
Posts: 10
Joined: Wed Feb 07, 2018 10:28 pm

Save Date in variable after executed script

Post by ALD Automotive »

Product: PowerShell Studio 2019 (64 Bit)
Build: v5.6.156
OS: Windows 10 Enterprise (64 Bit)
Build: v10.0.14393.0

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.

User avatar
Alexander Riedel
Posts: 7378
Joined: Tue May 29, 2007 4:43 pm

Re: Save Date in variable after executed script

Post 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
Alexander Riedel
SAPIEN Technologies, Inc.