I cleaned the textfile path reference up before using Write-Host, and as before, it shows exactly what you would expect in "Test Collection Script" for File Not found: the same key-value pair as above in the code box, but this time with a cleaned (but fictitious) path. Still, even though the output targets the standard datapoint FileError01 with a value of 1, and you can see it when testing the Collection script, by the time it's listed in the Raw Data polling results for any of the instances (for now I'm using the in-script list for Active Discovery to remove any consideration of File Not Found in AD), it doesn't show 1 in the FileLoadError01 column, but NoData.
FileLoadError01 datapoint key:
##WILDVALUE##.FileLoadError01
Collection script Write-Host with key-value pair:
Write-Host "$VM_FQDN_Path_cleaned.FileLoadError01=1" # $VM_FQDN_Path not found
return # I even tried "exit 0" rather than return here to see if that had an impact, but it didn't
Collection script output as seen in "Test Collection Script" (correct; used to trigger a File Not Found alert):
C-_ps_SocialDistortion-txt.FileLoadError01=1
Raw Data table for any of the instances, column value for the FileUploadError01 datapoint:
"NoData" (needs to be 1, which would trigger a warning)
---
HOWEVER, this exact same approach works fine for another standard datapoint set up the same way, with the below key and threshold set to a value of 1; it's just that in this case, the error is in the loop that iterates through the list after the file is found and read, not in the initial check to see if it exists:
##WILDVALUE##.SystemUptimeError01
Collection script Write-Host with key-value pair (in this case, I don't use "return" because it writes the key-value pair then moves on to the next item in the list:
Write-Host "$VM_FQDN.SystemUptimeError01=1" # Failed to retrieve CIM instance
In this case, not only does the "Test Collection Script" output show as correct (as above), but SystemUptimeError01 shows as value 1 rather than NoData in the Raw Data polling results of any of the instances, and the alert triggers.
I'm basically back to being stumped as to why one works that way and the other doesn't.