How to determine if a setting is available

This shouldn’t be complicated but I’m not sure how to do this.
I’m writing a script that reconfigures a variety of 5-port routers to how we actually use them, which is nothing like the default configuration. I want one part of the script to work like this:
IF ether3 has poe-out available,
set poe-out on ether3 to forced-on.
ELSE IF ether5 has poe-out available,
set poe-out on ether5 to forced-on.
END IF
The problem is, I don’t know how to tell if the poe-out setting is there. It’s there on an RB750UP but not on an RB750. I want to do this without looking up the model number so the script will run properly on any and all 5-port models, not just the ones I know.

Thx

Depending on the devices you need to support, you could always base it on /system routerboard model - from which you can pre-program on what to do for that model. This could be a bit more tedious if you are supporting a LARGE amount if different models but if its between 2 or 3 then its not bad.

If model contain “i” is poe capable on last ethernet
if model contain “0P” or “UP” is capable to poe from 2 to 5
if model contain “8P” is capable to poe from 1 to 8
if model contain “16P” is capable to poe from 1 to 16
if model contain “24P” is capable to poe from 1 to 24
if model contain “48P” is capable to poe from 1 to 48

This check if “poe” section are present or not, and if is present give number of interfaces with poe, if only one, print the name of the interface

:global poepresent false
:global interfaces 0
:global interfacename ""
:execute {/interface ethernet poe;:set poepresent true}
:delay 1s
:if ($poepresent) do={
            :set interfaces [:len [/interface ethernet poe find]]
            :put "Are present $interfaces PoE Interfaces"
            :if ($interfaces = 1) do={
                :set interfacename [/interface ethernet poe get [find] name]
                :put "The name of the only interface present is: $interfacename"
            }
    } else={:put "PoE not present"}