You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Currently we can set the default parameter values in a hashtable named WslDefaultParameterValues.
This is basically a Dictionary<string, string>.
Describe the solution you'd like
I would like to see a modification, e.g. $WslDefaultParameters.
This should check the type. If it is a string, then work like before.
If it is a scriptblock, then get the value at runtime by executiong the function.
Additional context
In case you are asking why I want this:
I am using a commandline tool accepting passwords and want to use PowerShell´s secret store for that.
Of course the last parameter is almost always needed and very clumsy to write in this notation.
So what I want to do, is store this expression as a default parameter.
But this does not work as when I put it this way in the dictionary, the $(xxx) part is not evaluated.
I can do the following: $WslDefaultParameterValues = @{ "ansible-playbook" = "--extra-vars ansible_become_pass=$((Get-Secret MySecret).Password | ConvertFrom-SecureString -AsPlainText)" }
This works of course, but now
$WslDefaultParameterValues[ "ansible-playbook"]
shows my password.
To make the usage conveniant, I would suggest accepting strings and functions. So the typical case works like before, but there is an additional option to make the default parameter generation dynamic.
The text was updated successfully, but these errors were encountered:
I am no exception to the typical user who only addresses the developers, if they face a problem. So I want at least to take this post here to thank you for your great module. Probably not too many are aware of this little gem, but this module makes working with PowerShell and WSL so much better.
Is your feature request related to a problem? Please describe.
Currently we can set the default parameter values in a hashtable named WslDefaultParameterValues.
This is basically a Dictionary<string, string>.
Describe the solution you'd like
I would like to see a modification, e.g. $WslDefaultParameters.
This should check the type. If it is a string, then work like before.
If it is a scriptblock, then get the value at runtime by executiong the function.
Additional context
In case you are asking why I want this:
I am using a commandline tool accepting passwords and want to use PowerShell´s secret store for that.
To combine these, I can to the following:
ansible-playbook playbook.yaml -i /hosts --extra-vars "ansible_become_pass=$((Get-Secret MySecret).Password | ConvertFrom-SecureString -AsPlainText)"
Of course the last parameter is almost always needed and very clumsy to write in this notation.
So what I want to do, is store this expression as a default parameter.
But this does not work as when I put it this way in the dictionary, the $(xxx) part is not evaluated.
I can do the following:
$WslDefaultParameterValues = @{ "ansible-playbook" = "--extra-vars ansible_become_pass=$ ((Get-Secret MySecret).Password | ConvertFrom-SecureString -AsPlainText)" }
This works of course, but now
$WslDefaultParameterValues[ "ansible-playbook"]
shows my password.
To make the usage conveniant, I would suggest accepting strings and functions. So the typical case works like before, but there is an additional option to make the default parameter generation dynamic.
The text was updated successfully, but these errors were encountered: