Functions/Get-MerakiOrganization.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
function Get-MerakiOrganization {
    Param(
        [Parameter(Mandatory=$true,HelpMessage='Please enter your Meraki API Key',ValueFromPipelineByPropertyName=$true)]
        $ApiKey
    )

    Begin {
        if ([Net.ServicePointManager]::SecurityProtocol -ne [Net.SecurityProtocolType]::Tls12) {
            [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
        }

        $BaseUri = 'https://api.meraki.com/api/v0'
        $Headers = @{
            'X-Cisco-Meraki-API-Key' = $ApiKey;
            'Content-Type' = 'application/json'
        }
    }

    Process {
        try {
            $Uri = '{0}/organizations' -f $BaseUri
            $Response = Invoke-RestMethod -Method Get -Uri $Uri -Headers $Headers
            $Response
        }
        catch {
            $_.Exception.Message
        }
    }

    End {}
}