Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Powershell: Generate a random Alphanumeric string
# Generate a random Alphanumeric string
Function Get-RandomAlphanumericString {
[CmdletBinding()]
Param (
[int] $length = 8
)
Begin{
}
Process{
Write-Output ( -join ((0x30..0x39) + ( 0x41..0x5A) + ( 0x61..0x7A) | Get-Random -Count $length | % {[char]$_}) )
}
}
# Write-Host ("Alfa Beta " | Tee-Object -Variable txt) ($txt.length)
Write-Host "A: "(Get-RandomAlphanumericString | Tee-Object -variable teeTime ) ("len=$($teeTime.length)")
Write-Host "B: "(Get-RandomAlphanumericString -length 22 | Tee-Object -variable teeTime ) ("len=$($teeTime.length)")
@KEV1L

This comment has been minimized.

Copy link

@KEV1L KEV1L commented Jul 3, 2018

Very helpful, thanks!

@j-i-m-s-t-e-r

This comment has been minimized.

Copy link

@j-i-m-s-t-e-r j-i-m-s-t-e-r commented Mar 18, 2020

teeTime Like it!

@NadalinVini

This comment has been minimized.

Copy link

@NadalinVini NadalinVini commented Sep 25, 2020

great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.