Is there something in $MyInvocation that does this? Or some way to extract it? I want the original text used for the arguments in the function call.
There are some caveats to using $myinvocation.line or $myinvocation.position. If you split the invocation to your command across multiple lines (using backtick) then .position and .line won't show you the full command. It is safer to use splatting, $args/$myinvocation.unboundarguments (and don't define any parameters to your function) or $input (if your function gets pipeline input), depending on what you want to do with the command line. If you need to preserve spaces, though, using .line or .position are your only options.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With