#Requires -Version 2.0 Function New-RandomString { Param([string]$source="123abcDEFg45hijk67MNO890",[int]$Length=7) $ofs="" [string]$newString=$source.ToCharArray() | Get-Random -count $length write-Output $NewString } #sample #New-RandomString -length 9