I have implemented some benchmarks in a script. It simply outputs:

Write-Output "Time to complete $secondselapsed" | Out-File -FilePath "$perflog"

This is for my own purpose when testing. I have a dozen or so in my script measuring different performances. I don’t want to have to comment them all out if I want to disable and then re-enabled them. Is there a way to just assign $perflog to some form of NULL?

Setting $perflog=$null just throws an error:

Out-File: Cannot bind argument to parameter 'FilePath' because it is an empty string.

I know Out-Null exists, but that doesn’t seem to help much here either.

Any suggestions?