Skip to content

Instantly share code, notes, and snippets.

@yufufi
Last active June 13, 2018 19:52
Show Gist options
  • Save yufufi/62c75377b9f23427d008a2bdfe4962cf to your computer and use it in GitHub Desktop.
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
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