Public/Get-specCurrentGroups.ps1

function Get-specCurrentGroups {
    <#
    .SYNOPSIS
        Retrieves the current TeamViewer groups membership from the local device's registry.
 
    .DESCRIPTION
        The Get-specCurrentGroups function queries the registry of the local device to retrieve its current TeamViewer groups membership.
        It returns an array of group names.
 
    .PARAMETER RegistryPath
        Specifies the registry path where the TeamViewer groups information is stored. Defaults to "HKLM:\SOFTWARE\WOW6432Node\TeamViewer".
 
    .PARAMETER RegistryValue
        Specifies the registry value name where the TeamViewer groups information is stored. Defaults to "TeamViewerManagedGroupsMembership".
 
    .EXAMPLE
        Get-specCurrentGroups
        Retrieves the current TeamViewer groups membership from the local device's registry.
 
    .NOTES
        Author : owen.heaume
        Version : 1.0
 
    #>



    [cmdletBinding()]

    param (
        [string]$RegistryPath ="HKLM:\SOFTWARE\WOW6432Node\TeamViewer",

        [string]$registryValue = "TeamViewerManagedGroupsMembership"        
    )
    
    try {
        [array]$currentGroups = Get-ItemProperty -Path $registryPath -Name $registryValue -ErrorAction stop | Select-Object -ExpandProperty $registryValue    
    } catch {
        return 1
    }

    if ($null -ne $currentGroups) {
        $currentGroups = $currentGroups -split ','
        
    } else {
        $currentGroups = @()
    }

    return $currentGroups
}