Last active
June 13, 2018 19:52
-
-
Save yufufi/62c75377b9f23427d008a2bdfe4962cf to your computer and use it in GitHub Desktop.
A powershell script that generates a password of arbitrary length and assigns to a vso variable
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param( | |
[string] $targetvariablename, | |
[int] $length | |
) | |
# create a list of characters to select from | |
$ascii=$null | |
for ($a = 33; $a -le 126; $a++) { | |
$ascii+=,[system.convert]::tochar($a) | |
} | |
for ($i = 0; $i -lt $length; $i++) { | |
$password+=($sourcedata | get-random) | |
} | |
write-host "##vso[task.setvariable variable=$targetvariablename;]$password" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment