Skip to content

Instantly share code, notes, and snippets.

Created April 18, 2015 17:34
What would you like to do?
function Test-Function {
This function will check for the existence of loaded functions.
This function will look at the currently loaded functions and report a true or false
based on whether the functions are loaded or not, or list any missing functions if the
ShowMissing parameter is used.
Test-Function 'My-Function'
Will return TRUE if 'My-Function' is found, or FALSE if it's not.
Test-Function @('My-Function1','My-Function2')
Will return TRUE if both functions are found, or FALSE if one, or both, are missing.
Test-Function @('My-Function1','My-Function2') -ShowMissing
Will return a list of any missing functions.
Author: Øyvind Kallstad
Date: 18.04.2014
Version: 1.0
param (
# Name of function(s) to check.
[Parameter(ValueFromPipeline, Position = 0)]
[string[]] $Name,
# If 'true', will list any missing functions.
[switch] $ShowMissing = $false
$return = $true
$missing = @()
foreach ($functionName in $Name) {
if (-not(Test-Path -Path "function:\\$($functionName)")) {
$return = $false
$missing += $functionName
if ($ShowMissing) {
Write-Output $missing
else {
Write-Output $return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment