We’re trying to write a custom value (text) to a custom registry key and then have the Syncro Agent (via Powershell Script) grab that data and write it to a custom asset field
@jeff I saw you and @VerandaTech going back and forth a bit about pushing RegKey Data to Custom Asset Fields in the post below:
To expand on the example, here are a couple of commands to store arbitrary string data in a registry key. This is system wide in HKLM so use an admin account to store the data.
Powershell to run from Syncro to pull registry item into custom asset field
## Required Syncro library module
Import-Module $env:SyncroModule
## Fetch value from registry
$TrackingData= Get-ItemPropertyValue "HKLM:\SOFTWARE\MSPNAME" -Name "Thing to track"
## Debug - show the value in the script output
Write-Host $TrackingData
## Store the value in a Syncro Asset custom field
Set-Asset-Field -Name "Tracking Data" -Value "$($TrackingData)"
I have not been able to test this very well. My scripts on the Mac side of Syncro don’t seem to be working.
#!/bin/bash
## Store the date in a text file
date > /tmp/test.txt
## Append some arbitrary text to the file starting with a line break
echo "\nScript ran successfully" >> /tmp/test.txt
## Read the text file into a variable called myvar
myvar=`cat /tmp/test.txt`
## Store the variable into a Syncro custom asset field called "Tracking Data"
syncro set-asset-field --name="Tracking Data" --value=$myvar