I have randomly bumped into this as I can clearly see that PATH variable is not populated in the process that I'm now starting as a service on Windows 11, while the same exact script when started from cmd works perfectly fine.
That said I was not able to find any official confirmation of this odd behaviour.
Does anybody know if this is expected behaviour on Windows 11 (and perhaps earlier versions too)?