OpsManager Shell commands in 3 state Monitor script

I’m running into an issue that makes me question if the script is actually taking in the cmdlets I’m running.

Basically I’m disabling a component group roll-up health for a component group in a DA and built a unit monitor, scripting 3 state, and look at the health of the objects below it individually using Get-Scomclassinstance.

For some reason, I’m getting different results with different component groups. Even when I take one of the exact scripts and paste it into another one.

Does the script have to target a server and it’s run on that particular one or does the management server run it?

Can someone confirm if the cmdlets for OpsManager work inside this scripting monitor? Do I have to import the module first? Do I have to connect to itself first using New-SCOMManagementGroupConnection? I don’t have access to the management server to produce logs. I do i have admin privileges though through the console.