Public/Tags/Get-PopuliTags.ps1
function Get-PopuliTags { [CmdletBinding(PositionalBinding=$true)] param ( [Parameter(Mandatory=$false)][ValidateLength(200,999)][string]$PopuliToken = $env:PopuliToken, [Parameter(Mandatory=$false)][ValidatePattern('^(?i)https:\/\/\S+\.populiweb\.com\/?$')][string]$BaseUrl = $env:PopuliBaseUrl ) if ($BaseUrl -match '\/$') { $BaseUrl = $BaseUrl -replace '\/$' } $header = @{ Authorization = $PopuliToken } $body = @{ task = 'getTags' } try { $response = Invoke-RestMethod -Uri "$BaseUrl/api/" -Method POST -ContentType 'application/x-www-form-urlencoded' -Body $body -Headers $header $tags = $response.response.tags.tag Write-Log "Returning $($tags.Count) tags" return $tags } catch { Write-Log "Unhandled exception" -LogType: error -ErrorObject $_ Write-Error $_ return $null } } |