Public/Get-Space.ps1
function Get-Space { [CmdletBinding( SupportsPaging = $true )] [OutputType([ConfluencePS.Space])] param ( [Parameter( Mandatory = $true )] [URi]$apiURi, [Parameter( Mandatory = $true )] [PSCredential]$Credential, [Parameter( Position = 0 )] [Alias('Key')] [string[]]$SpaceKey, [ValidateRange(1, [int]::MaxValue)] [int]$PageSize = 25 ) BEGIN { Write-Verbose "[$($MyInvocation.MyCommand.Name)] Function started" $resourceApi = "$apiURi/space{0}" } PROCESS { Write-Debug "[$($MyInvocation.MyCommand.Name)] ParameterSetName: $($PsCmdlet.ParameterSetName)" Write-Debug "[$($MyInvocation.MyCommand.Name)] PSBoundParameters: $($PSBoundParameters | Out-String)" $iwParameters = @{ Uri = "" Method = 'Get' GetParameters = @{ expand = "description.plain,icon,homepage,metadata.labels" limit = $PageSize } OutputType = [ConfluencePS.Space] Credential = $Credential } # Paging ($PSCmdlet.PagingParameters | Get-Member -MemberType Property).Name | ForEach-Object { $iwParameters[$_] = $PSCmdlet.PagingParameters.$_ } if ($SpaceKey) { foreach ($_space in $SpaceKey) { $iwParameters["Uri"] = $resourceApi -f "/$_space" Invoke-Method @iwParameters } } else { $iwParameters["Uri"] = $resourceApi -f "" Invoke-Method @iwParameters } } END { Write-Verbose "[$($MyInvocation.MyCommand.Name)] Function ended" } } |