How to run command in PowerShell?

I have an AppleScript right now that I can use remotely to run a scene. I want to use this on my PC as well but I’m not sure how to write it for PowerShell. Anything I try results in some type of error.

AppleScript:

do shell script "curl -k -X POST -H \"Authorization: Bearer MY_TOKEN_IS_HERE\" -H \"Content-Type: application/json\" -d '{\"entity_id\": \"scene.light_dim_20\"}' https://MY_SERVER:8123/api/services/homeassistant/turn_on"

curl is available in windows shell

And also in a linux shell if you’re using Home Assistant (on a RPi for exemple).

You need to be more precise to describe what you want to do.

So in windows, create a txt file, copy/paste the curl command, save and rename it as .cmd (instead of .txt)

I just want to enter a command to run a scene I have setup in Home Assistant. I have MQTT running.

curl is available on almost every system on earth.

Just open a cmd window and try the content of your AppleScript, it should work.

curl -k -X POST -H "Authorization: Bearer MY_TOKEN_IS_HERE" -H "Content-Type: application/json" -d '{"entity_id": "scene.light_dim_20"}' https://MY_SERVER:8123/api/services/homeassistant/turn_on

Now if you put it in a “.cmd” file, you can even double-click on it.

Thanks for the help.

I get an error on the closing }.
“unmatched close brace/bracket in URL”

Think I got it. Had to change the formatting to:

"{\"entity_id\": \"scene.light_dim_20\"}"

Ok, I could not test your curl, glad you found it.

1 Like

No problem, I appricate the guidance :slight_smile: