This is written so that $sourceData can be a string like the following. If you really want to pass $sourcedata as an array of char remove the [char[]] cast from the function.
$sourcedata="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-$"
Function GET-Temppassword() {
Param(
[int]$length=10,
[string[]]$sourcedata
)
-join ([char[]] $sourcedata | GET-RANDOM -count $length)
}
get-temppassword $sourceData 20
GVTXxF13ibnBK5AQOu-P