Quantcast
Channel: /r/powershell – How to Code .NET
Viewing all articles
Browse latest Browse all 8793

Get Function name within module

$
0
0

I am trying to create a function that standardises our verbose/debug messages and I am having problems getting the function name.

Obviously this will be part of another function, so it needs to look outside the current scope to get the function that is actually being run. I have been using the following code, which works but not when the function is part of a module:

 $Function = (Get-Variable -Scope 1 MyInvocation -ValueOnly).MyCommand.Name 

When it I import the function from a module, the variable only contains module.psm1. Anyone know how to get the function name when within a module?

Thanks

submitted by /u/G__Man
[link] [comments]

The post Get Function name within module appeared first on How to Code .NET.


Viewing all articles
Browse latest Browse all 8793

Trending Articles