Given the function object (i.e. $f = gi Function:\myfunc ), you can find the file name and other information (for example, line number) of the file in which the function is declared?
$f = gi Function:\myfunc
You are on the right track with gi . The ScriptBlock element of the function object has File and StartPosition among its properties:
gi
File
StartPosition
(gi function:\prompt).ScriptBlock.File
Or you can just go with:
${Function:myfunc}.File