REGKEY data to CUSTOM ASSET FIELDS

Good Morning, all! I am brand new to Syncro and am migrating from CW Automate (LabTech)

One of the things I’m trying to work through is replacing some of the automation and stuff that I already have set up in LabTech. I have done a little bit with Powershell - which I think is my answer here - but need a bit of help / confirmation. Let’s say for example, I wanted to pull a registry value from every asset periodically and store that value in a custom field, so that I could then run reports against it. I assume all I need is a basic powershell script to do something like… just as an example:

Get-ItemProperty -Path “HKLM:\System\CurrentControlSet\Control\Terminal Server” -Name “fDenyTSConnections”

And whatever that value is (0 or 1) - have it stored in a custom field called RDPSTATUS. Then, just set that script to run daily or whatever, so it catches machines that may be off one day but on the next. But then, at any given time, I can run a report against that RDPSTATUS field looking for all assets with a value of 0. I will also want the same type of thing for my antivirus of choice, to pull definition dates, software versions, whatever into custom fields.

Am I right on the method? And in SyncroMSP, how specifically is that done? What would the script look like for example? I know the command to reach the value (Get-ItemProperty) but how do I write that to a variable and then my custom field in Syncro? Thanks, and looking forward to joining this community!

Here is a short example that will pull the RDP fDenyTSConnections regkey value and store it in a Syncro asset custom field

In Syncro Admin - Custom Asset fields - Syncro Device (Manage Fields) create a new Text Field called ‘RDP Enabled’. Note: This will take a few moments to propagate. Once it’s visible in the asset down the left side. Create a new script with this code. Then from the asset scripts tab, add to queue, find this script you saved. Run once.

You can schedule it to run regularly per asset, but placing the script to run regularly from a policy is preferred.

## Required Syncro library module
Import-Module $env:SyncroModule
## Fetch value from registry - expecting 1 for enabled, 0 for disabled
$RDPEnabled = Get-ItemPropertyValue "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server" -Name "fDenyTSConnections"
## Debug - show the value in the script output
Write-Host $RDPEnabled
## Store the value in a Syncro Asset custom field
Set-Asset-Field -Name "RDP Enabled" -Value "$($RDPEnabled)"
2 Likes

Jeff - BRILLIANT! That is exactly what I was struggling with and looking for. Thanks so much!

In addition to grabbing the RDPSTATUS… I also wrote a second script that now grabs AV ENGINE VERSION, AV DEFS DATE and AV UI VERSION for me… which gives me something I didn’t even have with the LabTech setup.

A few more oddities but I’ll post those later in the appropriate places in the KB. Thanks again!

1 Like