$USERNAME$ stopped working within powershell variables

Backlog

$USERNAME$ stopped working within powershell variables

avatar

I have a Powershell script (remote) that launches an external process and takes parameters from the arguments field and the credentials. Until now, the script was working without issues. After an update (not quite sure which version caused this - probably the last 1-2 versions), the $USERNAME$ is not resolved if it is first assigned to a variable before being used.


Example of the original script:

$hostname = $args[0]
$port = $args[1]
$principal = $args[2]
$user = "$USERNAME$"
$password = "$PASSWORD$"

$additionalParameters = "-q -s $hostname -p $port -a partnernet -l $user -m $principal -L $password"

I have now changed the script to use the $USERNAME$ variable directly which seems to work.

$additionalParameters = "-q -s $hostname -p $port -a partnernet -l $USERNAME$ -m $principal -L $password"


If I remember correctly, the variable assignment intermediate step was made, because the reverse was true - the variable did not work when passed directly to the Start-Process command (code omitted here)

I presume that this is a bug and is not the intended behavior, since the changelogs do not mention any changes in this area.

All Comments (3)

avatar

Hello,

Thank you for reporting this issue.

I have been able to reproduce it with this simple script.

$user = "$USERNAME$"
$password = "$PASSWORD$"

Write-Host $user
Write-Host $password


If I use this one instead, then I can see the username.

$password = "$PASSWORD$"

Write-Host $USERNAME$
Write-Host $password


I have submitted a ticket to our developer team.

We will update this thread once a fix will be available.

Best regards,

Érica Poirier

avatar

Hello,

I wanted to let you know we identified the issue and made a fix. This will be available starting with our version 2024.2.20.0. We are hoping to release this version next week.

Regards,

Hubert Mireault

avatar

Thank you for the quick response and fix, I will test the new release when it comes out and let you know if the issue is fixed