Public/Set-specTVDeviceAlias.ps1

function Set-specTVDeviceAlias {
    <#
    .SYNOPSIS
        Renames a TeamViewer device using the specified alias and TeamViewer Management ID.
 
    .DESCRIPTION
        The Set-specTVDeviceAlias function renames a TeamViewer device using the provided alias and TeamViewer Management ID.
        It utilizes the Set-TeamViewerManagedDevice cmdlet to perform the renaming.
 
    .PARAMETER TeamViewerManagementID
        Specifies the TeamViewer Management ID of the device to be renamed.
 
    .PARAMETER NewAlias
        Specifies the new alias to be assigned to the TeamViewer device.
 
    .PARAMETER TVAPIKey
        Specifies the TeamViewer API key to authenticate the renaming operation.
 
    .EXAMPLE
        Set-specTVDeviceAlias -TeamViewerManagementID "123456789" -NewAlias "UKC-Device001" -TVAPIKey $secureApiKey
        Renames the TeamViewer device with the Management ID "123456789" to the new alias "UKC-Device001" using the provided API key.
 
    .NOTES
        Author : owen.heaume
        Version : 1.0
 
    #>


    param (
        [Parameter(Mandatory = $true)]
        [string]$TeamViewerManagementID,

        [Parameter(Mandatory = $true)]
        [string]$NewAlias,

        [Parameter(Mandatory = $true)]
        [securestring]$TVAPIKey
    )

    try {
        # Rename the device using the Set-TeamViewerManagedDevice cmdlet
        Set-TeamViewerManagedDevice -ApiToken $TVAPIKey -Device $TeamViewerManagementID -Name $NewAlias -ErrorAction Stop
        return 0
    } catch {
        Write-Host "Failed to rename TeamViewer device to $NewAlias. Error: $_" -ForegroundColor DarkYellow
        return 1
    }
}