Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get a list of custom Powershell functions?

Tags:

I use custom powershell functions to make my life easier.

Example:

# custom function > function build {cmd /c build.ps1}  # invoke the function > build 

This works great to allow me to run my build script quickly.
Unfortunately it's easy to forget all of the custom functions that I've created.

Is there a cmdlet that I can run to dump a list of my custom functions? Subsequently, once I know what those functions are, is there a cmdlet that I can run to delete ones that I no longer need?

like image 903
Chase Florell Avatar asked Mar 29 '13 00:03

Chase Florell


People also ask

How many functions are currently defined in your PowerShell environment?

There are two kinds of functions in PowerShell. We have a “basic” function and an advanced function. “Basic” functions are the simplest form of a function that can be created. They don't have any of the fancy built-in capabilities that advanced functions do.

Where are PowerShell functions stored?

To make your function available for all users save it in ProgramFiles\WindowsPowerShell\Modules\Gateway. This means, that you have to create a folder there, which has the same name as your file.

What is $Global in PowerShell?

Global: The scope that is in effect when PowerShell starts or when you create a new session or runspace. Variables and functions that are present when PowerShell starts have been created in the global scope, such as automatic variables and preference variables.

What is $_ called in PowerShell?

The “$_” is said to be the pipeline variable in PowerShell. The “$_” variable is an alias to PowerShell's automatic variable named “$PSItem“. It has multiple use cases such as filtering an item or referring to any specific object.


1 Answers

To get a list of available functions

> Get-ChildItem function:\ 

To remove a powershell function

# removes `someFunction` > Remove-Item function:\someFunction 
like image 142
Chase Florell Avatar answered Oct 11 '22 13:10

Chase Florell