Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 8 years and 4 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
That's all fine, the data is stored in $data variable but gets lost just when the -completedscript{} block finishes and leaves the jobtracker function. My question is, how do I store / pass the data from the block so it doesn't get lost when the jobtracker function ends? I was thinking that it has something to do with the Update-Jobtracker function that calls the scriptblock via invoke-command. Can you please help / guide me to better understanding of this framework? I read all about 'creating responsive forms' but couldn't find anything helpful.
Easiest way is a psobject. Merely assigning variables does not constitute data. You can see the difference in the shell. get-job will show if the job has data or not.
I posted code yesterday on jobtracker in the PSGUI topic.
Dan - the likelihood that the result is a PsObject already...
Just creating an object does not "store" anything.
We could output to a file. We could export to a CSV file. We could display in a textbox.
What does "store" mean? As used here, "store" is an ambiguous term and not a technical term.
I want to have access to the data outside of the jobtracker function but not output it to a file. Basically what I am trying to achieve is having a Job#1 return some data and save it outside of the job when it finishes. Then I need to run Job#2 which will also create very similar data and after it finishes I want to compare those results and out-file them to a text file.
The way I tried to achieve that was creating an object inside the scriptblock itself, then I can return it to "completed script" block but I'm not able to get it "outside" of the function after that. Think it's because the "completed script" gets processed in the "Update-Jobtracker" function with Invoke-Command,but the output doesn't get saved so that I could see it from outside after that. I don't want to mess with the jobtracker framework so maybe there is another approach I could use.
I wanted to provide a code I'm working with but anti-spam is blocking me from posting it (URL links are not allowed - there aren't any links in it tho).
noescape wrote:I wanted to provide a code I'm working with but anti-spam is blocking me from posting it (URL links are not allowed - there aren't any links in it tho).
To post links you need to use the add attachments or use the full editor and not the "quick" edit box.
Thanks for quick help, I already tried that though and it still got thrown out of the window as soon as the completedscript block ended. I will test again tomorrow and let you know.
BTW I didn't add any link to the reply, it's a false anti-spam bug on your forum. I added a powershell code and enclosed it in codebox. I had to remove the whole code to get past that.
The script scope works like you said, so thank you. The problem was that I pre-defined the variable somewhere else without setting the scope and then I was assigning the data to that variable setting the script scope over there instead (I guess it doesn't work that way).
Anyway, thanks for the fast aid, It was getting a little bit frustrating.
This topic is 8 years and 4 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.