Public/Get/Organisation/Get-NinjaOneOrganisationDocuments.ps1
#Requires -Version 7 function Get-NinjaOneOrganisationDocuments { <# .SYNOPSIS Gets documents from the NinjaOne API. .DESCRIPTION Retrieves documents from the NinjaOne v2 API. .OUTPUTS A powershell object containing the response. #> [CmdletBinding()] [OutputType([Object])] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', '', Justification = 'Uses dynamic parameter parsing.')] Param( # Filter by organisation ID. [Parameter(ValueFromPipelineByPropertyName, Mandatory)] [Alias('id')] [Int]$organisationId ) $CommandName = $MyInvocation.InvocationName $Parameters = (Get-Command -Name $CommandName).Parameters try { $QSCollection = New-NinjaOneQuery -CommandName $CommandName -Parameters $Parameters Write-Verbose 'Getting organisation documents from NinjaOne API.' $Organisation = Get-NinjaOneOrganisations -organisationId $organisationId if ($Organisation) { Write-Verbose "Retrieving organisation documents for $($Organisation.Name)." $Resource = "v2/organization/$($organisationId)/documents" } $RequestParams = @{ Method = 'GET' Resource = $Resource QSCollection = $QSCollection } $ActivityResults = New-NinjaOneGETRequest @RequestParams Return $ActivityResults } catch { New-NinjaOneError -ErrorRecord $_ } } |