I got a newline and carriage return at the end of the $mydir
value, so try trimming with something like this to see if that is your issue:
$Child = gci -path $mydir.Trim("`r`n") -r -Filter *.jpg
Update: Better yet, just lose the Out-String
in your function:
Return $StartDir