Skip to content

Conversation

@amadeo-alex
Copy link

@amadeo-alex amadeo-alex commented Jul 14, 2023

This PR:


PowerShell Command changes have been tested against following script:

$wshell = New-Object -ComObject Wscript.Shell
$wshell.Popup("runs " + $PsBoundParameters.Values + $args,1,"Done",0x1)
$PsBoundParameters.Values >> sumlogs.txt

and following scenarios:

  • normal path to the .ps1 script
  • normal path to the .ps1 script and spaces present
  • path to the .ps1 script containing non-safe characters and spaces

In all scenarios the payload value has been properly shown by the popup.
NOTE: due to how parameters are passed, they need to be retrieved with "$PsBoundParameters" instead of "args[]".

In addition this PR also adds an additional precheck in the "HandleActionReceived" function guarding against null payload (it can happen when payload is specified as an empty string ("") in Home Assistant.

@amadeo-alex amadeo-alex changed the title Fix: PowerShell command action params Fix: PowerShell command action params / PowerShell sensor encoding fix Sep 11, 2023
@amadeo-alex
Copy link
Author

Regarding the encoding issue reported in LAB02-Research/HASS.Agent#343, at some point a feature should be added which forces the PowerShell processes being spawned to use user-defined encoding.
This will allow users to then control the output encoding in PowerShell script using for example
[Console]::OutputEncoding = [System.Text.Encoding]::Unicode

That should allow for usage of any type of characters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant