---
title: "Create config functions"
slug: "create-config-functions"
abstract: ""
---
# Create config functions

Config functions are PowerShell functions that you can invoke from within a SIF configuration to access and calculate values that you can then pass to a task.

Because a config function is implemented as a PowerShell function, it benefits from all the features that PowerShell offers. This includes parameter validation, strict mode, requires, and others.

Config functions must always return a value, and this value can be used by other config functions or by tasks within a configuration.

## Config function parameters

Config function parameters are declared as normal PowerShell parameters. You can use validation and types to restrict the values that can be passed. This includes marking parameters as mandatory and support for multiple parameter sets.

When a config function is called from a configuration, the parameters are applied in the order that they are declared. If you want them to be applied in a different order, use the [Position](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_functions_advanced_parameters?view=powershell-5.1#position-argument) argument to specify the order.

The `Invoke-JoinConfigFunction` function declares the following parameters:

```csharp
Function Invoke-JoinConfigFunction {
    param(
        [Parameter(Mandatory=$true)]
        [psobject[]]$Values = @(),
        [Parameter(Mandatory=$false)]
        [string]$Delimiter = ","
    )

    # function code
}

```

In a configuration, this can be used as follows:

```csharp
{
    "Parameters": { 
        "Values": { "Type": "string[]", "DefaultValue": [ 1,2,3,4,5 ]
    },
    "Variables": {
        "Joined": "[join(parameter('Values'), '-')]
    }
}

```

When the `Joined` variable is evaluated, it results in a value of: `1-2-3-4-5`.

## Include config functions in a configuration

Once you have written a config function, it must be registered with SIF. You can include config functions in a configuration by packaging them as a PowerShell module and adding them to the `Modules` section of a configuration.

By using the `Register-SitecoreInstallExtension` cmdlet, the config function is made available for use in configurations. For example the following cmdlet registers the `Get-CustomJoin` cmdlet as the `CustomJoin` config function:

```

Register-SitecoreInstallExtension
-Command Get-CustomJoin -As CustomJoin -Type ConfigFunction

```

> [!note]
> You can also use the `-Force` parameter to replace an existing registered config function. In the following example, the default join config function is replaced with a custom cmdlet:
>
> Register-SitecoreInstallExtension -Command Get-CustomJoin -As Join -Type ConfigFunction –Force