System Tray Icon One-Liners

@RobE That should work, the one difference between what you have and what they use in their module is

# Env is not set in the module.ps1 or we would not need to set it.
$env:RepairTechSyncroApiUrl = 'https://{subdomain}.syncroapi.com'
$SyncroApiUrl  = $env:RepairTechSyncroApiUrl

Then when they actually use it they are doing

Call-Api -ApiHost "$($SyncroApiUrl -replace "{subdomain}", $Subdomain)"...

As this is only used one place in the script your FQDN will work fine, BUT they appear to have done it to make it easier to interchange subdomains throughout the script so you may want to consider using that String for the SyncroAPIUrl.

Thanks for the tip, Jordan. But I don’t see $SyncroApiUrl = $env:RepairTechSyncroApiUrltype in your own Import-SyncroModule – What am I missing?

Sorry that post could have been written more clearly.

(I’m on mobile so sorry in advance for lack of formatting(
The line $SyncroApiUrl = $env:RepairTechSyncroApiUrltype
was pulled from Syncro’s module.ps1. I was trying to show why I was recommending formatting the URL the way I was, but didn’t write it up to well.

Ohhh, gotcha. They’re now expecting {subdomain} as a hard string that THEY can replace internally. I was effectively doing their job for them, which still worked, but could theoretically bite me later if they change something in Kabuto/Syncro plumbing separation they’re up to.

1 Like

Tweaked for Jordan’s heads-up…

Updated for the API changes:

$co='YOUR_COMPANY_NAME'; 
$hd='YOUR_HELPDESK_URL'; 
$em='YOUR_EMAIL_ADDRESS'; 
$rk=(gp -Path 'HKLM:\SOFTWARE\WOW6432Node\RepairTech\Syncro');
$fp='C:\ProgramData\Syncro\bin\'; 
$env:SyncroModule=$fp+'module.psm1'; 
$env:RepairTechKabutoApiUrl='https://rmm.syncromsp.com'; 
$env:RepairTechSyncroApiUrl='https://{subdomain}.syncroapi.com'; 
$env:RepairTechSyncroSubDomain=$rk.shop_subdomain; 
$env:RepairTechFilePusherPath=$fp+'FilePusher.exe'; 
$env:RepairTechUUID=$rk.uuid; 
Import-Module -Name $env:SyncroModule -DisableNameChecking; 
$aID=[regex]::match($rk.SyncroOptions,'asset_id.\:.(\d*)').captures.groups[1].value; 
$aURL='https://'+$rk.shop_subdomain+'.syncromsp.com/customer_assets/'+$aID;
$wsh=(New-Object -ComObject Wscript.Shell); 
$nn=[Environment]::NewLine+[Environment]::NewLine; 
$sfp='C:\temp\sysTray-screenshot.jpg'; 
$wsh.Popup('Please wait a few seconds while we grab a screenshot...',3,'📷 Saving Screenshot',0+64); 
Get-ScreenCapture -FullFileName $sfp; 
$error.clear(); 
try{Upload-File -FilePath $sfp}catch{}; 
if(!$error){ 
Send-Email -To $em -Subject 'Screenshot Saved' -Body ($rk.LastUser+' screenshotted '+$aURL); 
if($wsh.Popup('Screenshot filed with '+$co+'.'+$nn+'Do you need to open a *new* ticket to Request Support?',0,'📷 Screenshot saved!',4+32) -eq 6){start $hd;}
}else{ 
Log-Activity -Message $error -EventName 'Syncro '+$co+' SysTray error'; 
$wsh.Popup('Error saving screenshot!'+$nn+'Please try again.',0,'📷 Screenshot FAILED',0+48); 
};

and condensed to the one-liner:

powershell.exe "$co='YOUR_COMPANY_NAME'; $hd='YOUR_HELPDESK_URL'; $em='YOUR_EMAIL_ADDRESS'; $rk=(gp -Path 'HKLM:\SOFTWARE\WOW6432Node\RepairTech\Syncro'); $fp='C:\ProgramData\Syncro\bin\'; $env:SyncroModule=$fp+'module.psm1'; $env:RepairTechKabutoApiUrl='https://rmm.syncromsp.com'; $env:RepairTechSyncroApiUrl='https://{subdomain}.syncroapi.com'; $env:RepairTechSyncroSubDomain=$rk.shop_subdomain; $env:RepairTechFilePusherPath=$fp+'FilePusher.exe'; $env:RepairTechUUID=$rk.uuid; Import-Module -Name $env:SyncroModule -DisableNameChecking; $aID=[regex]::match($rk.SyncroOptions,'asset_id.\:.(\d*)').captures.groups[1].value; $aURL='https://'+$rk.shop_subdomain+'.syncromsp.com/customer_assets/'+$AID; $wsh=(New-Object -ComObject Wscript.Shell); $nn=[Environment]::NewLine+[Environment]::NewLine; $sfp='C:\temp\sysTray-screenshot.jpg'; $wsh.Popup('Please wait a few seconds while we grab a screenshot...',3,'📷 Saving Screenshot',0+64); Get-ScreenCapture -FullFileName $sfp; $error.clear(); try{Upload-File -FilePath $sfp}catch{}; if(!$error){ Send-Email -To $em -Subject 'Screenshot Saved' -Body ($rk.LastUser+' screenshotted '+$aURL); if($wsh.Popup('Screenshot now on file.'+$nn+'Do you need to open a *new* ticket to Request Support?',0,'📷 Screenshot saved!',4+32) -eq 6){start $hd;} }else{ Log-Activity -Message $error -EventName 'Syncro $co SysTray error'; $wsh.Popup('Error saving screenshot!'+$nn+'Please try again.',0,'📷 Screenshot FAILED',0+48); };"

I made it a little easier to set your own info at the top. Same results otherwise:


Thanks guys. Works now!

1 Like

This is very strange. The one liner that just was updated for screenshots works (so far) only when I happen to be using some kind of remote desktop connection. My own PC and a laptop don’t. The laptop has a fresh install of Syncro. How do I troubleshoot the error? @RobE

I’ve never seen a difference between remote desktop and in-person.

BUT, I sometimes have trouble with Syncro not refreshing its system tray settings on some assets. I usually troubleshoot by adding a period to the end of the command name. If that period doesn’t show up, then I know the underlying command hasn’t synced out either. To “jiggle the handle”, sometimes I’ll move that asset out/back into the container that assigns the systray settings.

Sorry if I am late to this party, but what is the use case for allowing an end user to upload a file to an asset? Aside from screensot which they can already do from the tray icon ticket module, I can’t think of any reason to do that

I’m still getting an error on this. I recopied the original one liner from here, put the stuff in needed and still. It can’t seem to save it. I wish I could be more helpful on why this isn’t working.

Hi Mark. Our use case is that we don’t use Syncro’s PSA, so we can’t use the built-in ticket module, and had to roll our own.

Ben, are you getting any error messages? Probably not, since it handles them with the user-dumbed down “please try again” (needed since Syncro sometimes just times out on their upload).

Here’s a simplified/tested version of the critical bits (prep, then screenshot, then upload) – just paste into a powershell prompt:

$rk=(gp -Path 'HKLM:\SOFTWARE\WOW6432Node\RepairTech\Syncro');
$fp='C:\ProgramData\Syncro\bin\'; 
$env:SyncroModule=$fp+'module.psm1'; 
$env:RepairTechKabutoApiUrl='https://rmm.syncromsp.com'; 
$env:RepairTechSyncroApiUrl='https://{subdomain}.syncroapi.com'; 
$env:RepairTechSyncroSubDomain=$rk.shop_subdomain; 
$env:RepairTechFilePusherPath=$fp+'FilePusher.exe'; 
$env:RepairTechUUID=$rk.uuid; 

Import-Module -Name $env:SyncroModule -DisableNameChecking; 
$sfp='C:\temp\sysTray-screenshot.jpg'; 
Get-ScreenCapture -FullFileName $sfp; 
Upload-File -FilePath $sfp

All you SHOULD see is “Call-SyncroApi: success”, and the screenshot added to asset attachments.

I haven’t changed anything yet, but the error I get, I attached here.

May sound like a stupid question, but do you have a c:\temp folder? Just glanced over the script and don’t see any validation that the folder exist and to create if not.

1 Like

I renamed it to C:\TW because that already exists for most that would run this, if not all.

Good point, Jimmie. A safer version would be this:

$sfp=$env:temp+'\sysTray-screenshot.jpg';

Why would the script be available to everyone? It would be configured to be on the system tray like all the other system tray items by policy.

She’s talking about the portal. If you make a script available in the portal it’s available to all that have portal access. You can customize it per customer/site/person like you could if it was a system tray item.

Who uses the portal? I have tried, my clients do not like it. Our only users who use the portal are account payable people. We force them.

1 Like

Maybe im misunderstanding, usually I can start typing and it’ll pull up the scripts that are in the system, but for Execute a CMD it doesnt look to those?