Public/Remove-GhostPage.ps1
|
function Remove-GhostPage { <# .SYNOPSIS Deletes a page from the Ghost site. .DESCRIPTION Deletes a page permanently, whatever its status. Ghost has no recycle bin, which is why this function asks for confirmation; use -Confirm:$false to delete from a script. Nothing is returned. .EXAMPLE Remove-GhostPage -Id '5b7ada404f87d200b5b1f9c8' Deletes the page after confirmation. .EXAMPLE Get-GhostPage -Filter 'status:draft+title:~Untitled' | Remove-GhostPage -WhatIf Shows which untitled drafts would be deleted, without deleting them. .LINK https://docs.ghost.org/admin-api/pages/deleting-a-page #> [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')] [OutputType([void])] param( # Id of the page to delete. [Parameter(Mandatory, Position = 0, ValueFromPipelineByPropertyName)] [ValidateNotNullOrEmpty()] [string] $Id ) begin { Test-GhostConnection $resources = Get-GhostAPIData -Endpoint $MyInvocation.MyCommand.Name } process { try { $uri = New-URIString -Endpoint $resources.URI -Parameters $PSBoundParameters if ($PSCmdlet.ShouldProcess($Id, $resources.Description)) { $null = Submit-Request -Uri $uri -Method $resources.Method -Success $resources.Success } } catch { $PSCmdlet.ThrowTerminatingError($_) } } } |