Public/Add-JiraWatcher.ps1

function Add-JiraWatcher {
    <#
    .SYNOPSIS
        Fügt einem Issue einen Watcher hinzu.
    .PARAMETER IssueKey
        Key oder ID des Issues, z.B. "PROJ-123".
    .PARAMETER AccountId
        Atlassian Account ID des Nutzers, der als Watcher hinzugefügt werden soll.
    .EXAMPLE
        Add-JiraWatcher -IssueKey "PROJ-123" -AccountId "5b10a2844c20165700ede21g"
    #>

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

        [Parameter(Mandatory = $true)]
        [string]
        $AccountId
    )

    begin {
        $ErrorActionPreference = "Stop"
    }

    process {
        Invoke-JiraApi -Method Post -Path "/rest/api/3/issue/$IssueKey/watchers" -Body $AccountId | Out-Null
    }

    end {
        return Get-JiraWatcher -IssueKey $IssueKey
    }
}