Public/Remove-IAMCoreSyncRule.ps1
|
function Remove-IAMCoreSyncRule { [CmdletBinding(SupportsShouldProcess = $true)] param ( [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)] [ValidatePattern("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$")] # Is a guid connector object id [string]$Id ) process { $Existing = Get-IAMCoreSyncRule -Id $Id if (!$Existing.Id) { throw "IAM Core Sync Rule $Id not found" } if ($PSCmdlet.ShouldProcess("Delete IAM Core sync rule '$Id'")) { $Result = Invoke-RestMethod -Uri "$Script:APIRoot/sync/syncrules/$Id" -Headers (Get-IAMCoreHeader) -Method Delete if ($Result.IsSuccess) { return $Result.Data } else { throw "Failed to delete IAM Core sync rule: $($Result.ErrorMessage)" } } } } |