Script had two problems:
1.) Setting the config file does not affect the currently running instance. Using the WebUI API applies the change immediately. This does require the option "Bypass authentication for clients on localhost" to be enabled (WebUI\LocalHostAuth=false) ahead of time.
2.) The PortRangeMin setting is obsoleted. Bittorrent\Session\Port should be used now (https://github.com/qbittorrent/qBittorrent/issues/8324)
Script had two problems: 1.) Setting the config file does not affect the currently running instance. Using the WebUI API applies the change immediately. This does require the option "Bypass authentication for clients on localhost" to be enabled (WebUI\LocalHostAuth=false) ahead of time. 2.) The PortRangeMin setting is obsoleted. Bittorrent\Session\Port should be used now (https://github.com/qbittorrent/qBittorrent/issues/8324)