Public/Remove-MerakiOrganizationApplianceDnsLocalProfile.ps1

function Remove-MerakiOrganizationApplianceDnsLocalProfile {
<#
.SYNOPSIS
Removes local DNS profile for Meraki MX appliances in the specified organization in bulk.
 
.DESCRIPTION
Sends a POST request to the Meraki API to remove local DNS profile under an organization.
Requires a valid Meraki API key (AuthToken) and a JSON payload describing the DNS profile to remove.
If OrganizationID is not supplied, the function attempts to resolve it via Get-OrgID -AuthToken <token>.
If Get-OrgID returns the string "Multiple organizations found. Please specify an organization ID.",
the function will return that message and not perform the API call.
 
.PARAMETER AuthToken
The Meraki API key (X-Cisco-Meraki-API-Key). This parameter is mandatory.
 
.PARAMETER OrganizationID
The Meraki organization ID to apply the DNS profile to. If omitted, the function calls Get-OrgID -AuthToken <AuthToken>
to resolve a single organization ID. If multiple organizations are found, you must supply this parameter.
 
.PARAMETER ProfileID
The ID of the DNS profile to be removed. This parameter is mandatory.
 
.EXAMPLE
Remove-MerakiOrganizationApplianceDnsLocalProfile -AuthToken $apiKey -ProfileID $ProfileID
 
.LINK
https://developer.cisco.com/meraki/api-v1/
#>

    [CmdletBinding()]
    param (
        [parameter(Mandatory=$true)]
        [string]$AuthToken,
        [parameter(Mandatory=$false)]
        [string]$OrganizationID = (Get-OrgID -AuthToken $AuthToken),
        [parameter(Mandatory=$true)]
        [string]$ProfileID
    )
    If($OrganizationID -eq "Multiple organizations found. Please specify an organization ID.") {
        Return "Multiple organizations found. Please specify an organization ID."
    } else {
        try {
            $header = @{
                "X-Cisco-Meraki-API-Key" = $AuthToken
                "content-type" = "application/json; charset=utf-8"
            }
            
            $url = "https://api.meraki.com/api/v1/organizations/$OrganizationId/appliance/dns/local/profiles/$ProfileID"

            $response = Invoke-RestMethod -Method Delete -Uri $url -headers $header -UserAgent "MerakiPowerShellModule/1.1.3 DocNougat"
            return $response
        }
        catch {
        Write-Debug $_
        Throw $_
        }
    }
}