Public/Get-ChildPage.ps1
function Get-ChildPage { [CmdletBinding( SupportsPaging = $true )] [OutputType([ConfluencePS.Page])] param ( [Parameter( Mandatory = $true )] [URi]$apiURi, [Parameter( Mandatory = $true )] [PSCredential]$Credential, [Parameter( Position = 0, Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true )] [ValidateRange(1, [int]::MaxValue)] [Alias('ID')] [int]$PageID, [switch]$Recurse, [ValidateRange(1, [int]::MaxValue)] [int]$PageSize = 25 ) BEGIN { Write-Verbose "[$($MyInvocation.MyCommand.Name)] Function started" $depthLevel = "child" } PROCESS { Write-Debug "[$($MyInvocation.MyCommand.Name)] ParameterSetName: $($PsCmdlet.ParameterSetName)" Write-Debug "[$($MyInvocation.MyCommand.Name)] PSBoundParameters: $($PSBoundParameters | Out-String)" if (($_) -and -not($_ -is [ConfluencePS.Page] -or $_ -is [int])) { $message = "The Object in the pipe is not a Page." $exception = New-Object -TypeName System.ArgumentException -ArgumentList $message Throw $exception } if ($PsCmdlet.ParameterSetName -eq "byObject") { $PageID = $InputObject.ID } if ($Recurse) { $depthLevel = "descendant" } # depth = ALL $iwParameters = @{ Uri = "$apiURi/content/{0}/{1}/page" -f $PageID, $depthLevel Method = 'Get' GetParameters = @{ expand = "space,version,body.storage,ancestors" limit = $PageSize } OutputType = [ConfluencePS.Page] Credential = $Credential } # Paging ($PSCmdlet.PagingParameters | Get-Member -MemberType Property).Name | ForEach-Object { $iwParameters[$_] = $PSCmdlet.PagingParameters.$_ } Invoke-Method @iwParameters } END { Write-Verbose "[$($MyInvocation.MyCommand.Name)] Function ended" } } |