Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to determine if a function has been called in Powershell

I have a Big Script where i want to ignore a function call if it has been called already.

Am having a flag which is set to determine this now. But how do i do this without needing to have a flag or count for this.

Thanks!

like image 870
Pradebban Raja Avatar asked Dec 08 '25 06:12

Pradebban Raja


1 Answers

You can make the function re-write itself, essentially becoming a noop after the first invocation:

function TestFunction
 {
   'Do Stuff'
   function Script:TestFunction { Return }
 }
like image 131
mjolinor Avatar answered Dec 11 '25 10:12

mjolinor



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!