Modules/AzureDevOpsDsc.Common/Resources/Functions/Public/AzDoAnalyticsViewsPermission/Remove-AzDoAnalyticsViewsPermission.ps1

Function Remove-AzDoAnalyticsViewsPermission
{
    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $true)][string]$ProjectName,
        [Parameter(Mandatory = $true)][string]$GroupName,
        [Parameter(Mandatory = $true)][bool]$isInherited,
        [Parameter()][HashTable[]]$Permissions,
        [Parameter()][HashTable]$LookupResult,
        [Parameter()][Ensure]$Ensure,
        [Parameter()][System.Management.Automation.SwitchParameter]$Force
    )

    Write-Verbose "[Remove-AzDoAnalyticsViewsPermission] Started."

    $SecurityNamespace = Get-CacheItem -Key 'AnalyticsViews' -Type 'SecurityNamespaces'
    $Project           = Get-CacheItem -Key $ProjectName -Type 'LiveProjects'

    if ((-not $SecurityNamespace) -or (-not $Project))
    {
        throw "[Remove-AzDoAnalyticsViewsPermission] Security namespace or project not found. Cannot converge on '$ProjectName'."
    }

    $tokenString = '$/Shared/{0}' -f $Project.id

    $params = @{
        OrganizationName    = (Get-AzDoOrganizationName)
        SecurityNamespaceID = $SecurityNamespace.namespaceId
        TokenName           = $tokenString
    }

    Remove-AzDoPermission @params
}