Public/Set-Config.ps1

<#
    .SYNOPSIS
    Set the script level configuration

    .DESCRIPTION
    Sets the script level configuration

    .INPUTS
    None. You cannot pipe objects to Set-Config.

    .OUTPUTS
    None.

    .PARAMETER Config
    The configuration object
#>

function Set-Config {

    [CmdletBinding()]
    [OutputType([System.Void])]
    param(
        [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline)]
        [PSCustomObject]
        $config,

        [Parameter(Mandatory = $false, Position = 1)]
        [Switch]
        $SkipIamAuthentication
    )

    begin {
        Write-Verbose "[$($MyInvocation.MyCommand.Name)] Function started"
    }

    end {
        Write-Verbose "[$($MyInvocation.MyCommand.Name)] Complete"
    }

    process {
        Write-Debug "[$($MyInvocation.MyCommand.Name)] PSBoundParameters: $($PSBoundParameters | Out-String)"
        Set-Variable -Name __config -Scope Script -Value $config

        $script:__sfAuth = Invoke-SfAuthenticate

        if (-not $SkipIamAuthentication) {
            # authenticate IAM using information from the salesforce org's configuration
            $script:__iamAuth = Invoke-IamAuthenticate
        }
    }
}