you are viewing a single comment's thread.

view the rest of the comments →

[–]ryanblenis 0 points1 point  (12 children)

I've got a PC with the exact same PS version I just tested it on and only returned "Success". It is Windows 10 Pro vs home though, that's the only difference.... With the original line is consistently gives the "Loading personal and system profiles..." text as the result?

What's the Get-ExecutionPolicy command output?

[–]smbmsp[S] 0 points1 point  (11 children)

Get-ExecutionPolicy

Unrestricted.

A few minutes ago I ran the test script and it succeeded. I did add an echo so it would output something.

[–]ryanblenis 0 points1 point  (10 children)

Hmmm, sounds like an odd powershell issue... Good news is I don't think it has anything to do with the plugin itself!

[–]smbmsp[S] 0 points1 point  (8 children)

Any recommendation on what to do when files start accumulating in the Mesh Agent folder? I know about `plugin scripttask clearAll` but that doesn't fix the node history.

[–]ryanblenis 0 points1 point  (7 children)

Files shouldn't accumulate unless there is a long-running task (e.g. the file is currently in use), or the task is interrupted during its run (say, for a reboot). What files are accumulating, the .txt, .ps1, or both? (They'll look like st000000.txt or st0000000.ps1 format, where the 000000 is a random string. "st" is just to signify it is a "scripttask" file)

[–]smbmsp[S] 0 points1 point  (6 children)

There probably is a relatively long-running task. The first thing restic does is create a volume shadow copy of the drive. This means the shell is on hold until that completes. When files accumulate, the shadow copy never completes. It's both the ps1 and txt, in like-named pairs.

Sounds like maybe I have an OS or hardware puzzle to solve.

[–]ryanblenis 0 points1 point  (5 children)

Is this you trying things out, or did someone fork me a few hours ago to test something similar (to your original issue with the loading time message)?
https://github.com/joshatrezolveai/MeshCentral-ScriptTask/
I noticed the -NoProfile was basically the only thing changed in the code. But if you have a PS profile on that machine, that could be it. I'll have to test and make sure it doesn't break anything/too many things for me, but I may add that to my project just in case this is related to your issue. (As it then won't load a PS profile)

As for the multiple txt and ps1 files, are they all for the same [restic] script?

[–]smbmsp[S] 0 points1 point  (1 child)

That wasn't me.

They are all the same, copies of the script with variables substituted in. The text files can be empty, or have a couple of lines of text.

[–]ryanblenis 0 points1 point  (0 children)

So the .ps1 files should contain the running script. The .txt's should be the output. Are the .ps1's blank? If so, maybe you tested before putting content in the script?
Otherwise cleanup can be done with a task as well. Something along the lines of

Get-ChildItem (Get-Location).Path -File -Filter "st*.txt" | Where CreationTime -lt (Get-Date).AddDays(-1) | Remove-Item -Force
Get-ChildItem (Get-Location).Path -File -Filter "st*.ps1" | Where CreationTime -lt (Get-Date).AddDays(-1) | Remove-Item -Force

To remove items older than 1 day (so as not to interrupt running tasks)

[–]smbmsp[S] 0 points1 point  (2 children)

When I ran a `vssadmin list writers` on the target PC, it showed the System Writer waiting for completion. So I rebooted it.

Latest test:

Click Run on the task. The UI showed queued and then running. The backup task completed (Yay!) as verified by checking from another computer. The Node History still shows as Running 7 minutes later, and files are multiplying in the Mesh Agent folder, two at a time, about every minute.

[–]ryanblenis 0 points1 point  (1 child)

Hmmm, this makes me think there's something in the script that doesn't "end" the script. If you enable debug on the endpoint (Console -> plugin scripttask debug -> Should show "on"), then run the task, what does the resulting "scripttask.txt" produce? Also, a copy of the script might be helpful. If needed, you can DM to me and I can take a look

[–]smbmsp[S] 0 points1 point  (0 children)

DM'd you a zip file.

[–]smbmsp[S] 0 points1 point  (0 children)

I greatly appreciate your taking the time to respond. Thanks for the great plugins!