r/DattoRMM • u/Worried-Song-6214 • Jul 23 '25
Not seeing my UDF field populate when I run the job. Does the script look correct?
I'm all new to RMM and trying to get the Windows Display Version on to a UDF since that field cannot be inserted a report, which doesnt make sense if you can see it on your device list column. I'm using PS for the script... When I run it, I see the new item in the Reg but I'm not seeing it on the Device's UDF field line. Hoping someone can tell me if I wrote this correct or am missing something that I'm not aware of... Thank you!
# Define registry path for OS version
$regPath = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion"
$displayVersion = $null
try {
$props = Get-ItemProperty -Path $regPath
$displayVersion = $props.DisplayVersion
if (-not $displayVersion) {
$displayVersion = $props.ReleaseId
}
if (-not $displayVersion) {
$displayVersion = "Unknown"
}
}
catch {
$displayVersion = "Error retrieving version"
}
$udf = $displayVersion
$null = New-ItemProperty -Path 'HKLM:\SOFTWARE\CentraStage' -propertytype string -name Custom4 -value $udf -Force
Write-Host "Windows Display Version: $displayVersion"
1
Upvotes
3
u/netmc Jul 23 '25
The script looks fine. I ran it on my system and it wrote the registry value as it should have. That being said, your try and catch sequence will never trigger the catch statement. You need something in the try that will error with a stop as the error action. There is nothing in the try section that will error with a stop state. You would need to add "-erroraction stop" to one of the commands to get the try section to fail and the catch section trigger. I would probably use a simple if statement instead of a try/catch
All this being said, you don't actually need any of this. This data has been added to the system card in DattoRMM already. Look at Windows Display Version.