Public/Get-specMissingGroups.ps1

function Get-specMissingGroups {
    <#
    .SYNOPSIS
        Compares the current TeamViewer groups membership with the required groups, returning the missing groups.
 
    .DESCRIPTION
        The Get-specMissingGroups function compares the current TeamViewer groups membership with the required groups.
        It returns an array of group names that are missing from the current membership.
 
    .PARAMETER CurrentGroups
        Specifies an array of current TeamViewer groups that the computer is a member of.
 
    .PARAMETER RequiredGroups
        Specifies an array of required TeamViewer groups that the computer must be a member of.
 
    .EXAMPLE
        $currentGroups = Get-specCurrentGroups
        $requiredGroups = Get-specRequiredTVGroups -Persona "ExamplePersona" -TableName "ExampleTable" -StorageAccount "ExampleAccount" -SASToken "ExampleToken"
        $missingGroups = Get-specMissingGroups -CurrentGroups $currentGroups -RequiredGroups $requiredGroups
        Retrieves the missing TeamViewer groups based on the comparison of current and required groups.
 
    .NOTES
        Author : owen.heaume
        Version : 1.0
 
    #>


    [cmdletBinding()]

    param (
        [array]$currentGroups,

        [array]$RequiredGroups
    ) 

    # CurrentGroups contains the groups the computer is in, requiredGroups contains the groups the computer must be in.
    # Find required groups that the computer needs to be in
    $MissingGroups = Compare-Object -ReferenceObject $CurrentGroups -DifferenceObject $RequiredGroups | Where-Object { $_.SideIndicator -eq '=>' } | Select-Object -ExpandProperty InputObject

    # Return the missing groups
    return $MissingGroups
    
}