# Load Configuration Variables function Get-SectigoOrg { [CmdletBinding()] param ( [string]$ApiToken=$env:SectigoToken ) if (-Not $ApiToken) { $ApiToken=Read-Host } . $PSScriptRoot\..\Private\Set-Onload.ps1 [string]$OrganizationLookupUrl=$BaseAPIUrl + "/api/organization/v1" # 1. Prepare the Authorization Header $headers = @{ "Authorization" = "Bearer $ApiToken" "Content-Type" = "application/json" } . $PSScriptRoot\..\Private\Set-Onload.ps1 try { # Invoke the web request to the Sectigo API $Response = Invoke-WebRequest -Uri $OrganizationLookupUrl -Headers $Headers -Method GET # Check if the request was successful if ($Response.StatusCode -eq 200) { # Parse the JSON response $Organizations = $Response.Content | ConvertFrom-Json $Organizations|select-object id, name $Organizations.departments } else { Write-Error "Failed to retrieve organizations. Status Code: $($Response.StatusCode)" Write-Error "Response Content: $($Response.Content)" } } catch { Write-Error "An error occurred during the API call: $($_.Exception.Message)" } }