Public/Remove-DunePatchingWindowAssignment.ps1
|
<# .SYNOPSIS Remove a patching window assignment. .DESCRIPTION Removes an assignment that links a patching window to a deployment. Identify the assignment by providing a `Deployment` and `PatchingWindowId` or by providing a `PatchingWindow` and `DeploymentId`. Observes `ShouldProcess`. .PARAMETER DeploymentId The GUID of the deployment for the `PatchingWindow` parameter set. .PARAMETER Deployment A `DuneDeployment` object; pipeline input supported for the `Deployment` parameter set. .PARAMETER PatchingWindowId The GUID of the patching window for the `Deployment` parameter set. .PARAMETER PatchingWindow A `DunePatchingWindow` object; pipeline input supported for the `PatchingWindow` parameter set. .EXAMPLE PS> Remove-DunePatchingWindowAssignment -DeploymentId 3d8f6b5a-... -PatchingWindowId 4a7f... Removes the specified patching window assignment. .EXAMPLE PS> Get-DuneDeployment -Name "app" | Remove-DunePatchingWindowAssignment -PatchingWindowId 4a7f... Pipeline example removing an assignment for a deployment. #> function Remove-DunePatchingWindowAssignment { [CmdletBinding( SupportsShouldProcess, ConfirmImpact = 'None' )] param ( [Parameter(ParameterSetName = 'PatchingWindow')] [guid]$DeploymentId, [Parameter(ValueFromPipeline, ParameterSetName = 'Deployment')] [DuneDeployment]$Deployment, [Parameter(ParameterSetName = 'Deployment')] [guid]$PatchingWindowId, #inPS7 use System.TimeOnly [Parameter(ValueFromPipeline, ParameterSetName = 'PatchingWindow')] [DunePatchingWindow]$PatchingWindow ) begin {} process { Write-Debug "$($MyInvocation.MyCommand)|process" switch ($PSCmdlet.ParameterSetName) { 'Deployment' { $DeploymentId = $Deployment.Id } 'PatchingWindow' { $PatchingWindowId = $PatchingWindow.Id } } $Uri = "deployments/$DeploymentId/patchingwindows/$PatchingWindowId" if ($PSCmdlet.ShouldProcess($PatchingWindow.Name)) { $Null = Invoke-DuneApiRequest $Uri -Method DELETE } } end {} } |