That’s the bees-knees!
Filling the gaps in Syncro, this one saves a screenshot, uploads to its asset, prompts the user to open our (separate) helpdesk to make a ticket, and then opens that…
powershell.exe “$rk=(gp -Path ‘HKLM:\SOFTWARE\WOW6432Node\RepairTech\Syncro’); $fp=‘C:\ProgramData\Syncro\bin'; $env:SyncroModule=$fp+‘module.psm1’; $env:RepairTechApiBaseURL=‘syncromsp.com’; $env:RepairTechApiSubDomain=$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 ‘[your_email]’ -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 ‘http://[your_helpdesk_url]’;} }else{ Log-Activity -Message $error -EventName ‘Syncro [your_company] SysTray error’; $wsh.Popup(‘Error saving screenshot!’+$nn+‘Please try again.’,0,‘
Screenshot FAILED’,0+48); };”
I like the looks of this, but I’m not sure what needs to be changed. I’m no coder lol. I attempted to put in my subdomain and email, but nothing comes up at all on my test machine.
There’s a lot going on there crammed into a one-liner. Here’s an un-minimized + formatted version for readability:
$rk=(gp -Path 'HKLM:\SOFTWARE\WOW6432Node\RepairTech\Syncro');
$fp='C:\ProgramData\Syncro\bin\';
$env:SyncroModule=$fp+'module.psm1';
$env:RepairTechApiBaseURL='syncromsp.com';
$env:RepairTechApiSubDomain=$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 '[your_email]' -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 '[your_helpdesk_url]';}
}else{
Log-Activity -Message $error -EventName 'Syncro [your_company_name] SysTray error';
$wsh.Popup('Error saving screenshot!'+$nn+'Please try again.',0,'📷 Screenshot FAILED',0+48);
};
Here’s the English overview:
- reads out critical info from the registry
- sets environment variables so we can make Syncro API calls (since we’re not running in a Syncro script), specifically Get-ScreenCapture and Upload-File
- preps needed variables
- popups a user notice
- saves a screenshot
- tries to upload it to the asset, with error handling (Syncro’s API sometimes fails here)
- popups a confirmation and prompts the user for the helpdesk
- if yes, then opens that URL
The only thing you SHOULD have to do is fill-in-the-blanks for [your_email], [your_helpdesk_url], and [your_company].
You might want to reedit your singleline post, since it’s not marked as code all the single and double quotes got converted which won’t work.
Indeed I want to edit it, but can’t figure out how. (Am I missing something, or does the Syncro Community STILL have no Edit button?! )
I’ll just repost the one-liner :
powershell.exe "$rk=(gp -Path 'HKLM:\SOFTWARE\WOW6432Node\RepairTech\Syncro'); $fp='C:\ProgramData\Syncro\bin\'; $env:SyncroModule=$fp+'module.psm1'; $env:RepairTechApiBaseURL='syncromsp.com'; $env:RepairTechApiSubDomain=$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 '[your_email]' -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 '[your_helpdesk_url]';} }else{ Log-Activity -Message $error -EventName 'Syncro [your_company] SysTray error'; $wsh.Popup('Error saving screenshot!'+$nn+'Please try again.',0,'📷 Screenshot FAILED',0+48); };"
.
That oughta keep them from changing my quotes (wish I had similar for Syncro’s RMM-Alert scripting function, which also changes the data that we pass to its Category parameter).
Thanks. There’s a little pencil icon for editing your existing posts.
That worked with the edits you suggested. I thought it was just me! Thank you!
Unless I’m missing something your trying to do, I already got you covered on importing the syncro module in your own script
you could then use the menu button to generate a “RunScriptX” alert and set an AR to trigger the script.
Edit: haha looks like I didn’t scroll far enough before starting to post about how to load the module.
This is awesome… I finally had a chance to test it out and, thanks!
This doesn’t seem to be working right anymore. I keep getting error while saving screenshot. Does it still work for you? I was just about to deploy this out there too.
Thanks for the heads-up, Ben.
Yes, I’m seeing an issue too, and just dug down to the root error - screenshot:
That file definitely exists on my system, so it looks to me like Syncro’s Upload-File capability is just down right now.
Anyone wanna chase support about Upload-File ?
(I can’t right now so I’m just warning my techs.)
In their example, the file path is in quotes, yours are missing from the SS. Also, some things won’t work from PS, they must be in a script. I just created this script and it worked fine, uploaded the file.
Import-Module $env:SyncroModule
Upload-File -FilePath "c:\temp\keys.txt"
I reached out to support. Alexandra pointed out that their sample script ‘Syncro (Files) - Upload File To An Asset Record’ still works. I’m giving it a college try, but I bet a resolution via support is a long-shot (since Syncro’s functions normally fail outside Syncro’s own scripting context).
So that brings us back to @jordanritz : Is Import-SyncroModule still working for you? It’s not here.
The only script I use regularly that upgrades a file is still working, I haven’t tried uploading anything with the Syncro module outside of a Syncro script though that would be the first functionality I’m aware of that needs to be run in a script. I’ll try to look at it later if I get a moment.
Looking at your error I’m guessing there is another $env var somewhere I am not setting
Your test won’t work because you’re not going through Syncro. Therefore, the upload file command is not associated to an asset, so it won’t know where to upload the file to. Try putting this into a script and running it on the asset.
Import-Module $env:SyncroModule
Upload-File -FilePath "c:\temp\sysTray-screenshot.jpg"
I didn’t include quotes because they’re only needed if there are spaces in the path. But it’s the same with quotes.
Also, Import-Module $env:SyncroModule is already part of JordanRitz’ Import-SyncroModule function. But it’s the same when I run that again.
Well I found it. The beauty of these sort of work arounds is that things change. I wasn’t monitoring for Syncro to change their env vars so some functionality has been broken for a little while I guess.
I’ve updated the Import-SyncroModule script now.
Sweet, good sleuthing Jordan! That works for me too.
It looks like they replaced these vars:
$env:RepairTechApiBaseURL and $env:RepairTechApiSubDomain
with these vars:
$env:RepairTechKabutoApiUrl, $env:RepairTechSyncroApiUrl, and $env:RepairTechSyncroSubDomain
(So they’re distinguishing Syncro from Kabuto – wonder there that’s headed…)
I’ll update my screenshot one-liner in a moment.
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://'+$rk.shop_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://'+$rk.shop_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: