Skip to content

Remove-MgmtGraphDeviceCompliancePolicy

MgmtGraph: Deletes an Intune device compliance policy

#Requires -Version 5.1
#Requires -Modules Microsoft.Graph.DeviceManagement

[CmdletBinding()]
Param (
    [Parameter(Mandatory = $true, Position = 0)]
    [string]$Identity
)

Process {
    try {
        $params = @{
            'DeviceCompliancePolicyId' = $Identity
            'Confirm'                  = $false
            'ErrorAction'              = 'Stop'
        }

        Remove-MgDeviceManagementDeviceCompliancePolicy @params
        
        $result = [PSCustomObject]@{
            Id        = $Identity
            Action    = "DeviceCompliancePolicyRemoved"
            Status    = "Success"
            Timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
        }

        Write-Output $result
    }
    catch {
        throw
    }
}

Specifies the ID of the device compliance policy to remove.

An interactive directory of PowerShell scripts.