You can’t use certain automatic variables in your param block (such as $PSCommandPath, $MyInvocation, $PSCmdlet, etc); they don’t work the way you’d expect them to.
Instead, you can move that logic inside the script or function itself. For example:
param ( [Parameter(Mandatory=$False)] [string]$OutputFile = $null ) if (-not $OutputFile) { $OutputFile = "$PSCommandPath\output_$(Get-Date -Format yyyy_dd_MM_hh_mm).log" }