PowerShell_Scripts/base/Get-RandomString.ps1

8 lines
298 B
PowerShell

param(
[Parameter(Mandatory)]
[int]$Length,
[string]$AllowedChars="ABCDEFGHIJKLMNOPQVRSTUWXYZabcdefghijklmnopqvrstuwxyz0123456789"
)
1..$Length | ForEach-Object {
$AllowedChars[$([math]::Round($(Get-Random -Minimum 0 -Maximum ($AllowedChars.Length)),0))]
} | Join-String