Script results report

We recently deployed a script that runs daily on around 120 endpoints.

Is there anyway to find out if the script has ran, was successful or failed? Like a report or something similar.

The only way I found was to select each asset and see the result, but surely there has to be a better way to find out more about the scheduled script after the time has passed.

You can create a custom field on an asset, and then Set-Asset-Field to update that field.
From there you could report on that field.

How MSPs Automatically Set Asset Custom Fields Using Scripting in Syncro - SyncroMSP

Careful though, with that number of assets, there is a possibility you might trigger API Limits and get throttled. This isn’t too bad though, you just may want to add something to help stagger the execution time with something like this

$seconds = Get-Random -Minimum 1 -Maximum 120
Write-Host "Pausing for $seconds to stagger execution time"
Start-Sleep -Seconds $seconds

#Your Script Continues here

Thank you for your help. I am trying to find out the exact syntax because after running the script the custom field doesn’t get updated.

How can I manually use the Syncro PS module so that I can test the script? I don’t know how to import the module.

A better solution might be to just monitor for failures within your script, and if it doesn’t do what you expect then have it throw an RMM alert. That way you aren’t wasting any time with successes, and you are exclusively triaging failures. You also won’t run into throttling issues with the API when mass running scripts. From the Automated Remediation module, you could optionally pick those up and depending on severity take additional action outside of just opening the alert, like creating a ticket or sending email notifications.

@Andy I will look into it, thanks.

Still the initial question is valid. There needs to be a way to see if the scripts ran or not, and on which endpoints.

PS: @KevinC managed to get the script to update the field going. Thanks for the tip.

Yep, it’s not something supported today in the way you are expecting. Quite possible we see this next year. It’s something I’d like to have added.

Down at the bottom of the New/Edit Script page you should have a “Powershell Quick Help”

You should have an example for Set-Asset-Field (and other commands) in that.

For Set-Asset-Field - I copied it below

# This can write to your Asset Custom Fields. Use it to store adhoc information that isn't currently surfaced.
Set-Asset-Field -Name "CustomFieldName" -Value "New Custom Field Value"

The module itself is at $env:programdata\Syncro\bin\module.psm1 but it is not something that you can just import-module and be off running with locally easily.

You can, open the Module in VS Code or similar and browse through the module to get an idea of how the PowerShell is working and what APIs it is using to make a call.

Do Be aware, though, that a good number of these methods are internal, and you cannot easily debug them or access them (For example Call-SyncroAPI or Invoke-WebRequest20)

You can get a very limited view of the commands by doing Get-Help though

CD $env:ProgramData\Syncro\bin\
Import-Module Module.psm1 -verbose
Get-Command -Module module

Get-Help Send-Email

1 Like

I would love to see the Syncro Powershell Module with much improved Help.

For example, currently a method might be

function Upload-File ($Subdomain, $FilePath) {
  $fileJson = try {
    $output = cmd /c $FilePusherPath $FilePath 2`>`&1
    ConvertFrom-Json20 -InputObject $output
  } catch {}
  $result = Call-SyncroApi `
    -Subdomain $Subdomain `
    -Path "/api/syncro_device/files/upload_file_from_url" `
    -Data @{
      uuid = $UUID;
      url = $fileJson.url;
      filename = $fileJson.filename;

and generate a very limited help like this

Versus a more fleshed out version - like this example I whipped up.

Agreed, but just between us, they need to improve their overall documentation first (in my opinion).
Something like this:

Veeam Help Center

Another option for reporting is to do log entries:
Log-Activity -Message "Activity description" -EventName "Event name"
Then you can query them using the Asset Activity Audit report.

1 Like

Good idea, but still will have to stagger execution for api throttling mitigation.


Not if you are only tagging failures.

Maybe you underestimate how much of a failure I am!