Public/Remove-DunePatchingWindow.ps1
|
function Remove-DunePatchingWindow { [CmdletBinding(SupportsShouldProcess)] param ( [Parameter(Mandatory, ParameterSetName = "Name", Position = 0)] [string]$Name, [Parameter(Mandatory, ParameterSetName = "Id")] [guid]$Id, [Parameter(Mandatory, ParameterSetName = "PatchingWindow", ValueFromPipeline)] [DunePatchingWindow]$PatchingWindow ) begin { Write-Debug "$($MyInvocation.MyCommand)|begin" $BaseUri = "patching/windows" } process { Write-Debug "$($MyInvocation.MyCommand)|process" switch ($PSCmdlet.ParameterSetName) { 'Name' { Write-Debug "$($MyInvocation.MyCommand)|process|$($PSCmdlet.ParameterSetName)|$($Name)" $PatchingWindow = Get-DunePatchingWindow -Name $Name } 'Id' { Write-Debug "$($MyInvocation.MyCommand)|process|$($PSCmdlet.ParameterSetName)|$($Id)" $PatchingWindow = Get-DunePatchingWindow -Id $Id } 'PatchingWindow' { Write-Debug "$($MyInvocation.MyCommand)|process|$($PSCmdlet.ParameterSetName)|$($PatchingWindow.Id)" } Default { return } } $Uri = $BaseUri, $PatchingWindow.Id -join "/" if ($PSCmdlet.ShouldProcess($PatchingWindow.Name)) { $Null = Invoke-DuneApiRequest $Uri -Method DELETE } } end {} } |