Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've defined a dynamic function in powershell, like this:

> function test { dir -r -fil *.vbproj | ft directory, name }

Then I can just type test and run that function, piping it to other commands, etc. Pretty handy.

Is there a way I can get the definition of the command? Can I echo out the code for my function test? (Without having to go back through my history to where I defined it?)

share|improve this question

2 Answers 2

up vote 6 down vote accepted

For a function called test:


Or if the function name contains a hyphen (eg. test-function):



(Get-Command test).Definition
share|improve this answer
(Get-Command Test).Definition

That is how I normally get definitions.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.