SecretServer icon indicating copy to clipboard operation
SecretServer copied to clipboard

generate password if password is empty

Open Plork opened this issue 9 years ago • 3 comments

see https://thycotic.force.com/support/s/article/PowerShell-Add-Update-Secret-Example for example.

Plork avatar Sep 13 '16 20:09 Plork

I can't test this at the moment.

Jaykul avatar Sep 26 '16 05:09 Jaykul

Only problem with this I had was the $script scoped Templates variable I mailed you about. I removed it locally and then this works.

Op ma 26 sep. 2016 om 07:06 schreef Joel Bennett [email protected]:

I can't test this at the moment.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/RamblingCookieMonster/SecretServer/pull/16#issuecomment-249480120, or mute the thread https://github.com/notifications/unsubscribe-auth/AEBGLxgNpYxvMz8p8XagGp_vVFwQ3FUoks5qt1LHgaJpZM4J8Hr8 .

Plork avatar Sep 26 '16 07:09 Plork

the Templates variable is a script scoped variable. I guess this is so you don’t have to get the templates everytime. This has a weird side effect tho I can’t explain.

A noteproperty gets added with to $Field with the values of the input parameters. Somehow these extra properties get added to the $script:secretTemplates as well. So the template in the script scope gets the values that are added to $field.

I would have thought that because you create a new variable $fields = $Template.Fields it would “copy” the $template variable into a new one and the the original does not gets altered.

I say this because I edited the script to allow to leave the password field empty. That way thycotic wil generate a password based on the requirements specified in the template. (So I don’t have to generate a password myself.) But because the script scoped $secretTemplates got the values of the $Fields variable the 2nd time I run the script the values of the first loop are still in there. My “if password is empty” fails because of this. (it’s only empty the first iteration).

Plork avatar Sep 26 '16 07:09 Plork