Passing fileinfo to function

this is my function
function Write-Log
# Param1 help description


    $logfile = "c:\$(get-date -format 'ddmmmmyyyy_hhmmtt').txt"

    $FullName | Out-File -Append -FilePath $logfile 

I want to pass fileinfo object to this function but I get error:
Write-Log : The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties
do not match any of the parameters that take pipeline input."

Please advice

Hi Itamar,

I think it’s because you don’t appear to be defining $FullName.

If you’re trying to reference the FullName property of the $FileInfo object, you need to refer to it like this

$FileInfo.FullName | Out-File -Append -FilePath $logfile

You will need to add ValueFromPipeline=$true to your parameters if you want something like below to work:

Get-Item -Path C:\Windows\Explorer.exe | Write-Log