Public/Get-MerakiOrganizationUplinksStatuses.ps1

function Get-MerakiOrganizationUplinksStatuses {
    <#
    .SYNOPSIS
    Retrieves the uplink statuses for all the devices in an organization.
 
    .DESCRIPTION
    The Get-MerakiOrganizationUplinksStatuses function retrieves the uplink statuses for all the devices in the specified Meraki organization. You can optionally filter the results by network, device serial number, or SIM card ICCID.
 
    .PARAMETER AuthToken
    The API token to use for authentication. This parameter is mandatory.
 
    .PARAMETER OrgId
    The ID of the organization for which to retrieve the uplink statuses. If not specified, the function retrieves the uplink statuses for the first organization in the list of organizations for which the user has privileges.
 
    .PARAMETER perPage
    The number of entries per page to return. If not specified, the function returns all the entries in a single page.
 
    .PARAMETER startingAfter
    A pagination parameter that specifies the starting point for the next page of results. If not specified, the function starts at the first page.
 
    .PARAMETER endingBefore
    A pagination parameter that specifies the ending point for the previous page of results. If not specified, the function ends at the last page.
 
    .PARAMETER networkIds
    An array of network IDs to use as a filter. If not specified, the function retrieves the uplink statuses for all the networks in the organization.
 
    .PARAMETER serials
    An array of device serial numbers to use as a filter. If not specified, the function retrieves the uplink statuses for all the devices in the organization.
 
    .PARAMETER iccids
    An array of SIM card ICCIDs to use as a filter. If not specified, the function retrieves the uplink statuses for all the SIM cards in the organization.
 
    .EXAMPLE
    PS C:\> Get-MerakiOrganizationUplinksStatuses -AuthToken "my_api_key" -OrgId "12345" -networkIds "NW_1234","NW_5678" -serials "Q2XX-XXXX-XXXX","Q2YY-YYYY-YYYY"
 
    Retrieves the uplink statuses for the specified networks and devices in the organization.
 
    .EXAMPLE
    PS C:\> Get-MerakiOrganizationUplinksStatuses -AuthToken "my_api_key" -OrgId "12345" -iccids "898XXXXXXX5XXXXXXX1","898XXXXXXX5XXXXXXX2"
 
    Retrieves the uplink statuses for the specified SIM cards in the organization.
 
    #>

    [CmdletBinding()]
    param (
        [parameter(Mandatory=$true)]
        [string]$AuthToken,
        [parameter(Mandatory=$false)]
        [string]$OrganizationID = (Get-MerakiOrganizations -AuthToken $AuthToken).id,
        [parameter(Mandatory=$false)]
        [int]$perPage = $null,
        [parameter(Mandatory=$false)]
        [string]$startingAfter = $null,
        [parameter(Mandatory=$false)]
        [string]$endingBefore = $null,
        [parameter(Mandatory=$false)]
        [array]$networkIds = $null,
        [parameter(Mandatory=$false)]
        [array]$serials = $null,
        [parameter(Mandatory=$false)]
        [array]$iccids = $null
    )
    try {
        $header = @{
            "X-Cisco-Meraki-API-Key" = $AuthToken
            "Content-Type" = "application/json"
        }
        $queryParams = @{}
        if ($perPage) {
            $queryParams['perPage'] = $perPage
        }
        if ($startingAfter) {
            $queryParams['startingAfter'] = $startingAfter
        }
        if ($endingBefore) {
            $queryParams['endingBefore'] = $endingBefore
        }
        if ($networkIds) {
            $queryParams['networkIds[]'] = $networkIds
        }
        if ($serials) {
            $queryParams['serials[]'] = $serials
        }
        if ($iccids) {
            $queryParams['iccids[]'] = $iccids
        }
        
        $queryString = New-MerakiQueryString -queryParams $queryParams
        $URI = "https://api.meraki.com/api/v1/organizations/$OrganizationID/uplinks/statuses?$queryString"
        $response = Invoke-RestMethod -Method Get -Uri $URI -Header $header
        return $response
    } catch {
        Write-Error $_
    }
}