Executing Powershell commands - execution context?
Hey peops, I'm wondering... I can set up a PowerShell command linked with a button in HA, so far, so well-known. I'm wondering however what the actual context of the command is. Environment seems to be that of SYSTEM (I see no user env vars in the process). What about the working directory? Where is the command executed? What privileges does it have? And especially, can I change the context? I would like to tell the command in which working directory it shall run etc. Would this be worth a feature request (if not already possible)?
Cheers
5 Replies
Help us Help Others!
To help others find answers, you can mark your question as solved via
Right click solution message -> Apps -> ✅ Mark Solution

Help us Help You!
Please don't delete messages or posts because it makes it impossible to understand what happened. If you don't want your messages to be seen then don't post here.
We will help as soon as possible.
While you're waiting you can try the following:
- Checkout the documentation. - Search here in discord for previously solved similar issues.
@DrR0x
No special elevation, afaik context is .exe of Hass.agent
@Amadeo can confirm
For privileged commands you need to setup a scheduled task
There's old documentation here which should still work
This is all for normal commands, ie CMD
Idk about PowerShell tho
I also see your trying to control ollama and stuff, Ive done this before as well. Depending on what you want I may already have config for it you could use
powershell commands set on hass.agent level will be executed with the same permissions as the user that launched the app
those set on a satellite level will have permissions of the user that the service is running - i.e. system
the working directory depends whether it's a command or ps1 script - for commands it's not set, for ps1 scripts it's the directory where script is located