Quite an old post, but I recently found a way to do this without any additional 3rd party tools.
TL;DR:
In Windows 11, go to Settings > System > For Developers and enable Developer Mode, Device Portal, and Restrict to Loopback Connections Only. Disable Authentication. Go to http://localhost:50080/#Bluetooth to find the ID of your already-paired Bluetooth device; convert it to base64. Then the following command will work from the command line:
curl -d "" http://localhost:50080/api/bt/connectdevice?deviceId={ID_in_base64}
Longer version:
This solution takes advantage of the Windows Device Portal, which lets you administer your PC through web requests. Read more about what it can do here. Go to Settings > System > For Developers and enable Developer Mode, then enable Device Portal. This will trigger the installation of the Developer Mode Package, which can take a few minutes and may require a reboot. Once it’s enabled, enable Restrict to Loopback Connections Only. This is very important for security reasons; it means that you will only be able to access the Device Portal from your local PC. Otherwise, anyone on the same network will be able to read all the files on your PC. Once you’ve enabled that, you can safely disable Authentication. Alternatively, you can leave Authentication on, but keep in mind you will have to specify the username and password in plaintext in your web requests later.
Once that’s done, you will see the URL for the Device Portal, which should look like http://localhost:50080, though maybe the port number might be different. Go to that URL and you will see the Device Portal; select Bluetooth in the sidebar to see your Bluetooth Devices. Assuming your Bluetooth device is already paired, you will see it in the list even if it’s currently disconnected. Copy the full ID of your Bluetooth device and convert it to base64 using a website such as https://base64.guru/converter.
Finally, you can use the REST API to connect or disconnect your Bluetooth device. The easiest way is to use curl, which is installed by default in Windows these days. But you can also use the requests package in Python if you want to do something even more fancy. The URLs to connect or disconnect your device are:
http://localhost:50080/api/bt/connectdevice?deviceId={ID_in_base64}
http://localhost:50080/api/bt/disconnectdevice?deviceId={ID_in_base64}
To use curl, include the -d flag with empty quotes (which sets the Content Length to 0), then the URL, like so: curl -d "" {url}