System on battery (UPS)/AC/Power fail?

Does anyone know how to determine if Windows 10 is on battery (specifically a UPS) or AC power. I have tried what I thought would work, and it does detect power and/or AC on a laptop, but it does not accurately detect the change when using a “desktop”. I know Microsoft changed how this works when they released Vista. I want to send this information to the ST cloud.

look at the ups service… you can plug into most ups via serial or usb and either the stock ups service that comes with windows or a specific vendors s/w like apc… can monitor and do stuff based on it.

Yeah, been there done that. Sorry, any other ideas?