A community member inquired about automating device group assignment in ControlUp based on a specific registry key value. The initial approach discussed involved writing a PowerShell script to read the registry key and create a custom index in ControlUp, which could then feed into a workflow for moving devices to the appropriate device group. This method also opened possibilities for using the data in dashboards, creating alerts for registry changes, and triggering remediation workflows.
A practical PowerShell script example was shared to demonstrate how to write, read, and output a registry key value under the current user (HKCU). This script was integrated with ControlUp’s Device Events by printing the output between defined event markers. Subsequently, a more detailed script was contributed, which collects registry information along with system and timestamp metadata, outputs it as a compressed JSON object, and supports error handling if the registry key access fails. This script is intended to run periodically to populate ControlUp’s data index, providing the basis for alerting and workflow triggers.
The recommended implementation steps include adding the script to the environment to gather registry data regularly, setting up alerts to trigger on specific registry values, and using ControlUp workflows with webhooks to move devices to the correct device groups based on the registry data. While alerts were initially used for this purpose, the community acknowledged the drawback of proliferation—needing many alerts for multiple groups—and expressed a preference to rely more on workflows for automation, preserving alerts for genuine issues.
To advance beyond alerts, the suggestion was made to leverage ControlUp’s API to retrieve custom data directly, enabling workflows to act on this real-time data without spawning numerous alerts. This approach supports scalable device management workflows, automating group assignments effectively. A recommendation was offered to engage ControlUp Customer Success Management (CSM) or Professional Services for further assistance with complex workflow setups integrating API data extraction. The discussion underscores the evolving use of ControlUp’s scripting, alerting, and workflow capabilities to streamline device group management based on registry key states.
For further reference, ControlUp’s official documentation on custom data scripting, workflows, and alerts can be found at https://docs.controlup.com, and detailed learning modules are available via ControlUp Academy at https://cuacademy.controlup.com.
Read the entire ‘Automating Device Group Assignment in ControlUp Workflows Using Registry Key Data’ thread below:
Morning All
I want to build a workflow to move device to the correct Device Group based on a reg key
is this possible
I feel that i would first need to write a script that will read the reg key and create a custom index and then try to build a workflow
^ this method to me makes sense – could also be used for a mini widget in a dashboard or create an alert if that reg got changed -> remediation (back to workflow)
I’ve been thinking about it…
tried this, as a first step:
“`$registryPath = “HKCU:\Software\TestPath”
$propertyName = “TestValue”
$valueToSet = “ControlUpTest123”
# 1. Create key if it doesn’t exist
if (-not (Test-Path $registryPath)) {
New-Item -Path $registryPath -Force | Out-Null
}
# 2. Write/Set the registry value
Set-ItemProperty -Path $registryPath -Name $propertyName -Value $valueToSet -Type String
# 3. Retrieve and output the registry value
$retrievedValue = Get-ItemPropertyValue -Path $registryPath -Name $propertyName
Write-Output(“### SIP EVENT BEGINS ###”)
Write-Output “Retrieved Registry Value: $retrievedValue”
Write-Output(“### SIP EVENT ENDS ###”)“`
this reports into Device Events
let me think now about the Group part
so, here is a rudimentary approach
Script:
“`[string]$strDate = Get-Date -Format ‘dd-MM-yyyy’
[string]$strSystemDrive = $env:SystemDrive
$registryPath = ‘HKCU:\Software\TestPath’
$propertyName = ‘TestValue’
# Read registry value (HKCU requires user context)
$testValue = $null
$registryError = $null
try {
$regItem = Get-ItemProperty -Path $registryPath -Name $propertyName -ErrorAction Stop
$testValue = $regItem.$propertyName
}
catch {
$registryError = $_.Exception.Message
}
# Build output object for the data index
$myObject = [PSCustomObject]@{
Date = $strDate
‘System drive’ = $strSystemDrive
RegistryPath = $registryPath
PropertyName = $propertyName
TestValue = $testValue
Hostname = $env:COMPUTERNAME
CollectedAt = (Get-Date).ToUniversalTime().ToString(‘o’)
}
if ($registryError) {
$myObject | Add-Member -NotePropertyName ‘TestValueError’ -NotePropertyValue $registryError
}
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
Write-Output ‘### SIP DATA BEGINS ###’
$myObject | ConvertTo-Json -Compress
Write-Output ‘### SIP DATA ENDS ###’“`
1. Add the script
2. Run periodically to populate the data index
3. Set up the alert to fire on certain value, and call a workflows webhook
4. Set up the workflow to change the Group for the associated_id device
give this a try, but might need to contact your CSM or Professional Services for additional assistance
Thanks for the reply Able
I build a script today that pulls in all the data from the reg key and it works 70% of the org done
I created an alert today and it worked but I want to move away from alerts
I need to create 26 alerts to move devices to the correct groups
I have already so many alerts that’s doing these things and want workflows to start taking over these things so that alerts are real alerts and events
If you want move from alerts, you would then need to Get Custom Data to pull the data from the API
That’s what I want to try in the morning
Hope I get it right
Continue reading and comment on the thread ‘Automating Device Group Assignment in ControlUp Workflows Using Registry Key Data’. Not a member? Join Here!
Categories: All Archives, ControlUp Dashboards, ControlUp Scripts & Triggers, ControlUp Workflows
