Read-Host returns a string or secure string... not an array.
So when $test gets passed an argument for Get-RandomElement, it's trying to get the "count" of a string (which returns nothing) and the Random Object is interpreting that as Zero.
See this for an example to illustrate:
$random = new-object Random
$test = read-host
INPUT: "1","2","3"
$random.next($test.count)
Your function when used with Read-Host is returning the $test[0] character every time (which happens to be " in your example).
Gaurhoth
"MiroslavK" <MiroslavK@discussions.microsoft.com> wrote in message news

D9B9064-A84F-4DED-9C47-BB03B06CE559@microsoft.com...
> this works great
> --------------------------------------------
> function Get-RandomElement($Array)
> { $Array[ $Random.Next( $Array.Count ) ] }
>
> $test="1", "2", "3", "4", "5", "6"
>
> $Random=New-Object Random
>
> $Message = Get-RandomElement $test
> $Message
> --------------------------------------------
> but, if I change this line:
> $test="1", "2", "3", "4", "5", "6"
> and put this line:
> $test = Read-Host "input"
> (input is: "1", "2", "3", "4", "5", "6")
>
> i'm getting single " as result always. whats wrong ?