Public/Update-specRegistryWithGroups.ps1

function Update-specRegistryWithGroups {
    <#
    .SYNOPSIS
        Updates the registry with the specified TeamViewer groups for a device.
 
    .DESCRIPTION
        The Update-specRegistryWithGroups function updates the registry with the specified TeamViewer groups for a device.
        It takes the registry path, registry value, and an array of groups as parameters and sets the registry value with
        the comma-separated list of groups.
 
    .PARAMETER RegistryPath
        Specifies the registry path where the TeamViewer groups information will be stored. Defaults to "HKLM:\SOFTWARE\WOW6432Node\TeamViewer".
 
    .PARAMETER RegistryValue
        Specifies the registry value name where the TeamViewer groups information will be stored. Defaults to "TeamViewerManagedGroupsMembership".
 
    .PARAMETER Groups
        Specifies an array of TeamViewer groups that need to be updated in the registry.
 
    .EXAMPLE
        Update-specRegistryWithGroups -Groups @("Group1", "Group2", "Group3")
        Updates the registry with the specified TeamViewer groups.
 
    .NOTES
        Author : owen.heaume
        Version : 1.0
 
    #>


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

        [Parameter(Mandatory=$false)]
        [string]$registryValue = "TeamViewerManagedGroupsMembership",

        [Parameter(Mandatory=$true)]
        [array]$Groups
    )

    $newGroupsValue = $Groups -join ","
    try {
        $null = Set-ItemProperty -Path $registryPath -Name $registryValue -Value $newGroupsValue -ea stop
        return 0
    } catch {        
        return 1
    }
}