I tried your script, I set it as a condition for a login policy and it works fine for me. However, there is an issue with the message modules when set to run with a login policy, it looks like I only set it up to work with checkin/startup policies, and it results in the toec-ui crashing. That is most likely why you are seeing the error you posted, it indicates that toec-ui is not running. I'll need to fix this in the next release.