Public/New-CollectionGroupLinkSync.ps1

<#
.SYNOPSIS
    Triggers a sync for a collection group link in the Fortytwo Collections API.

.DESCRIPTION
    This function triggers a sync for a collection group link in the Fortytwo Collections API.

#>

function New-CollectionGroupLinkSync {
    [CmdletBinding(DefaultParameterSetName = "Default")]
    param (
        [Parameter(Mandatory = $true,ValueFromPipeline = $true)]
        [ValidatePattern("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$", ErrorMessage = "Id must be a valid GUID.")] # Is a guid connector object id
        [string] $Id,

        [Parameter(Mandatory = $false)]
        [ValidateSet("Enabled", "Disabled")]
        [string] $Enabled
    )

    process {
        if (-not $Script:APIRoot -or -not $Script:AccessTokenProfile) {
            throw "Not connected to Fortytwo Collections. Please run Connect-Collections first."
        }

        # Create the URI
        $Uri =  "$Script:APIRoot" -f "group-link", "/group-links/$Id/sync"

        Write-Verbose "Triggering sync for collection group link. URI: $Uri"
        Invoke-RestMethod -Uri $Uri -Headers (Get-CollectionHeader) -Method POST
    }
}