The most efficient way to shutdown computers in a computer outage is through UPS devices. When the power gets down, the software that comes with the UPS will immediately initiate the shutdown procedure. You can't do it the other way because when the power goes down, the routers/switches will turn off as well making it impossible to connect using the network.
It's better to do this automatically using UPS devices, rather than connecting to each one individually.