Skip to content
Clifra-Jones edited this page Jul 29, 2022 · 17 revisions

Welcome to the Meraki-API-V1 wiki!

This module follows up on the Meraki-API V0 module adding new functionality incorporated in the new v1 API. We use this module in our company to manage 2 Meraki Organizations. While we have tested many for the function in this module I cannot attest that it is 100% bug free. Use any function that updates configurations with caution. If possible, test on a less critical network.

Contributor Note: This module is now separated into multiple files/folders reflecting the change in the API. Files are organized based on Organization, Networks, Devices and Products.

Command Reference

Organizational Functions

Set-MerakiAPI

  • Description: Save configuration information in the user profile.
  • Parameters:
    • APIKey:
      • Type: String
      • Mandatory: True
      • Description: Meraki API Key
    • OrgID:
      • Type: String
      • Description: Organizational ID
    • profileName:
      • Type: String
      • **Description: Create a named profile using this name.
    • Usage: Providing only the API Key will create named profiles for all the organization you have access to using the organization name are the profile name. This may not be the best approach as Organization names usually have multiple words separated by spaces. A better approach would be to create the default profile by providing the APIKey parameter and the OrgID parameter to create the default profile, then create named profile by providing the OrgID parameter and the profileName parameter with a more memorable profile name.

You can provide the API Key with any combination of parameters, if you already have an existing configuration file and provide a different API key you will be prompted to overwrite the existing configuration file.

Set-MerakiProfile

  • Description: Set the default profile to the named profile.
  • Parameters:
    • profileName:
      • Type: String
      • Description: Name of the profile to use.

Get-MerakiOrganizations

  • Description: Retrieve the Organization information the user has access to.

  • Parameters:

    • APIKey:
      • Type: String
      • Mandatory: True
      • Description: Meraki API Key
  • Alias: GMOrgs

Get-MerakiOrganization

  • Description: Retrieve an organization.

  • Parameters:

    • OrgId:
      • Type: String
      • Mandatory: True
      • Description: Organization ID
  • Alias: GMOrg

Get-MerakiNetworks

  • Description: Retrieve All networks in the Organization

  • Alias: GMNets

Get-MerakiNetwork

  • Description: Retrieve a specific network

  • Parameters:

    • networkId:
      • Type: String
      • Mandatory: True
      • Description: The ID of the network to retrieve
  • Alias: GMNets

Get-MerakiOrganizationConfigTemplates

  • Description: Get configuration templates

  • Parameters:

    • OrgID:
      • Type: String
      • Description: Organization ID. If omitted will be read from config file.
  • Alias: GMOrgTemplates

Get-MerakiOrganizationDevices

  • Description: Get all devices in an organization

  • Parameters:

    • OrgID:
      • Type: String
      • Description: Organization ID, if omitted pulled from configuration file.
  • Alias: GMOrgDevs

Get-MerakiOrganizationAdmins

  • Description: Get Organization Administrators

  • Parameters

    • OrgID:
      • Type: String
      • Description: Organization Id. If omitted, then pulled from config file.
  • Alias: GMOrgAdmins

Get-MerakiOrganizationConfigurationChanges

  • Description: Get Change log entries.
  • Parameters:
    • OrgID:
      • Type: String
      • Description: Organization ID. If omitted then pulled from config file
    • StartTime:
      • Type: DateTime
      • Description: Start date to pull logs (cannot be > 365 days old)
    • EndDate:
      • Type: DateTime
      • Description: End date to pull logs.
    • TimeSpan:
      • Type: Number
      • Description: Time span in days prior to today to pull logs. Cannot be > than 365 days prior to current date. If used, do not specify Start and End Dates.
    • *PerPage:
      • Type: Number
      • Description: Number of records per page. 3 - 5000 The default is 5000
    • NetworkID:
      • Type: String
      • Description: Network ID to filter logs by.
    • AdminID:
      • Type: String
      • Description: Admin ID to filter logs by.

Examples Filter logs for last 10 days by Administrator.

Get-MerakiOrganizationAdmins | Where-Object {$_.Name -eq "John Doe"} | Get-MerakiOrganizationConfigurationChanges -TimeSpan 10

Filter logs for changes to the Miami network that occurred between 6/1/2020 and 6/30/2020

Get-MerakiNetworks | Where-Object {$_.Name -like "Miami"} | Get-MerakiOrganizationConfigurationChanges -StartTime "06/01/2020" -EndTime "06/30/2020"

  • Alias: GMOrgCC

Get-MerakiOrganizationThirdPartyVPNPeers

  • Description: Get third party VPN peers for the Organization

  • Parameters:

    • OrdID:
      • Type: String
      • Description: Organization ID
      • If omitted it will be read from configuration file.
  • Alias: GMOrg3pVP

Get-MerakiOrganizationInventory

  • Description: Get inventory for the organization

  • Parameters:

    • OrgID:
      • Type: String
      • Description: Organization ID
      • If omitted will be read from configuration file
  • Alias: GMOrgInv

Network Functions

Get-MerakiNetwork

  • Description: Retrieve a specific network

  • Parameters:

    • NetworkID:
      • Type: String
      • Mandatory: True
      • Description: The ID of the network to retrieve
  • Alias: GMNet

Get-MerakiNetworkDevices

  • Description: Retrieve all devices in a network.

  • Parameters:

    • id:
      • Type: String
      • Mandatory: True
      • Accepts value from pipeline: True
      • Accepts value from pipeline by property name: True
      • Description: Network ID
  • Alias: GMNetDevs

Get-MerakiNetworkEvents

  • Description: Get Meraki network events

  • Parameters:

    • id:
      • Type: String
      • Mandatory: true
      • Accepts value from pipeline: True
      • Accepts value from pipeline by property name: True
      • Description: Network ID
    • ProductType:
      • Type: productTypes
      • Mandatory: True
      • Description: Can be one of wireless, appliance, switches, systemManager, camera, cellularGateway,
    • includedEventTypes:
      • Type: String[]
      • Description**: Array of event types to include.
    • excludedEventTypes:
      • Type: String[]
      • Description: Array of event types to exclude.
    • deviceMac:
      • Type: String
      • Description: MAC address of device to filter on
    • deviceName:
      • Type: String
      • Description: Name of device to filter on.
    • clientName:
      • Type: String
      • Description: Name of client to filter on.
    • clientIP:
      • Type: String
      • Description: IP of client to filter on.
    • clientMac:
      • Type: String
      • Description: MAC address of client to filter on.
    • smDeviceName:
      • Type: String
      • Description: System Manager name to filter on.
    • smDeviceMac:
      • Type: String
      • Description: System Manager MAC to filter on.
    • perPage:
      • Type: Number
      • Description: Number of event to retrieve per page. Can be 3-5000, 5000 is default.
    • startingAfter:
      • Type: DateTime
      • Description: Get events after this date time.
        • If omitted, the call will retrieve the number of events specified by the pageSize parameter prior to the time specified in the endingBefore parameter.
    • endingBefore: Get events ending before this date time.
      • If omitted, the call will retrieve the the number of events specified in the pageize parameter after the time specified in the startingAfter parameter.
      • If both startingAfter and endingBefore are omitted the call will retrieve the number of events specified in the pageSize parameter prior to the current date, time.
    • first: Get the first result page.
    • prev: Get the previous result page.
    • next: Get the next result page.
    • last: Get the last result page.
  • Alias: GMNetEvents

Note: You can get a list of event types in use for a network use the Get-MerakiNetworkEventTypes

Examples

Get content filtering network events for a network.

Get-MerakiNetworks |{$_.Name -like "Dallas"} | Get-MerakiNetworkEvents -includedEventTypes 'cf_block' -ProductType appliance

Get network events for a specific client Get-MerakiNetworkEvents -clientName 'DALJohnDoe'

Paging

The maximum number of events you can retrieve per call is 1000. There are many events and 1000 events may only span a time period of a few minutes. To retrieve more events you can use subsequent function calls with the paging parameters.

In the following command we retrieve the the content filtering events for the Dallas network for the month of June.

Get-MerakiNetworks |{$_.Name -like "Dallas"} | Get-MerakiNetworkEvents -includedEventTypes 'cf_block' -ProductType appliance -startingAfter "06/01/2020" -endingBefore "06/30/2020" -pageSize 50

This call will retrieve the first 50 events that meet the time span specified. There are significantly more events that meet this criteria. To retrieve the next page of events reissue the call and append the -next paging parameter.

Get-MerakiNetworks |{$_.Name -like "Dallas"} | Get-MerakiNetworkEvents -includedEventTypes 'cf_block' -ProductType appliance -startingAfter "06/01/2020" -endingBefore "06/30/2020" -pageSize 50 -next

If -endingBefore is not specified, -last will retrieve the page prior to the current date & time.

If -startingAfter is not specified, -first will not return a page.

If you issue a subsequent call without a paging parameter, paging is reset.

Examples: Get devices in a specific network

Get-MerakiNetworkDevices -id N-XXXXXXXXXXXXXXX

Get-MerakiNetworkEventTypes

  • Description: Get event types in use for a network.

  • Parameters:

    • id:
      • Type: String
      • Mandatory: True
      • Accepts value from pipline: True
      • Accepts value from pipeline by property name: True
      • Description: Network ID.
  • Alias: GMNetET

Device Functions

Get-MerakiDevice

  • Description: Get a Meraki Device

  • Parameters:

    • NetworkId:
      • Type: String
      • Mandatory: True
      • Description: Network ID to retrieve the device from
    • serial:
      • Type: String
      • Mandatory: True
      • Description: Serial number of the device.
  • Alias: GMDev

Start-MerakiDeviceBlink

  • Description: Blink the LEDs on the device.

  • Parameters:

    • networkId:
      • Type: String
      • Mandatory: True
      • Accepts value from pipeline: True
      • Accepts value from pipeline by property name: True
      • Description: Network ID of the device.
    • serial:
      • Type: String
      • Mandatory: True
      • Accepts value from pipeline: True
      • Accepts value from pipeline by property name: True
      • Description: Serial number of the device.
    • Duration:
      • Type: Number
      • Description: Duration in seconds to blink the LEDs
    • Duty:
      • Type: Number
      • Description: The duty cycle as the percent active
    • Period
      • Type: Number
      • Description: The period in milliseconds.
  • Alias: StartMDevBlink

Restart-MerakiDevice

  • Description: Reboot a Device

    • Parameters:
      • serial:
      • Type: String
      • Mandatory: True
      • Description: Serial number of the device.
  • Alias: RestartMD

Appliance Functions

Get-MerakiNetworkApplianceContentFilteringCategories

  • Description List all available content filtering categories for an MX network.

  • Parameters:

    • id:
      • Type: String
      • Mandatory: True
      • Accepts value from pileline: True
      • Description: Network ID
  • Alias: GMNetAppCFCats

Get-MerakiNetworkApplianceContentFiltering

  • Description: Return the content filtering settings for an MX network

  • Parameters:

    • id:
      • Type: String
      • Mandatory: True
      • Accepts value from pipeline: True
      • Accepts value from pipeline by property name: True
      • Description: Network ID
  • Alias: GMNetCF

Update-MerakiNetworkApplianceContentFiltering

  • Description: Update the networks content filtering rules

    • NOTE: This is a REPLACE operation not a merge! See examples below
  • Parameters:

    • id:
      • Type: String
      • Mandatory: True
      • Accepts value from pipeline: True
      • Accepts value from pipeline by property name: True
      • Description: Network ID
    • allowedURLPatterns:
      • Type: String[]
      • Description: String array of URL patterns
    • blockedURLPatterns:
      • Type: String[]
      • Description: String array of URL patterns
    • blockedURLCategories:
      • Type: Object[]
      • Description: object Array of URL Categories [do not modify this list using the API!]
    • urlCategoryListSize:
      • Type: CategoryListSize
      • Description: Either 'topSites' or 'fullList'
    • ContentFilteringRules:
      • Type: Object[]
      • Description: An object containing the above content filtering rules.
        • You cannot use this parameter if you use the above perimeters. This must be used by itself.
  • Alias: UMNetAppCF

Examples You must pull the Content Filtering Rules using the function Get-MerakiNetworkApplianceContentFiltering and then modify the properties of that object.

Adding a new URL to the blocked URL Pattern

$cfr = Get-MerakiNetworks | Where-Object {$_.Name -like "Dallas} | Get-MerakiNetworkApplianceContentFiltering

$cfr.blockedUrlPatterns += "example.com"

Get-MerakiNetworks | Where-Object {$_.Name -like "Dallas"} | Update-MerakiNetworkApplianceContentFiltering -allowedUrlPatterns $cfr.allowedUrlPattern -blockedUrlPatterns $cfr.blockedUrlPatterns -blockedUrlCategories $cfr.blockedUrlCategories -urlCategoryListSize $cfr.urlCategoryListSize

or

Get-MerakiNetworks | Where-Object {$_.like "Dallas"} | Update-MerakiNetworkApplianceContentFiltering -ContentFilteringRules $cfr

Updating Templates

If you have networks bound to templates, you should update the template and allow the template to trickle the changes down to the bound network.

$cfr = Get-MerakiOrganizationConfigTemplates | Where-object {$_.Name -eq "Org-Tremplate"} | Get-MerakiNetworkApplianceContentFiltering

$cfr.clockedUrlPatterns += "example.com"

Get-MerakiOrganizationConfigTemplates | Where-Object ($_.Name -eq "Org-Template"} Update-MerakiNetworkApplianceContentFiltering -ContentFilteringRules $cfr

To get a list of networks not bound to a template use:

Get-MerakiNetworks | Where-Object {$_.configTemplateID -eq $null}

Add-MerakiNetworkApplianceContentFilteringRules

  • Description: This is a simpler way to update the filtering rules. With this function you do not have to pull the rules before updating.

  • Parameters:

    • id:
      • Type: String
      • Mandatory: True
      • Accepts value from pipeline: True
      • Accepts value from pipeline by property name: True
      • Description: Network ID
    • allowedUrlPatterns
      • Type: String[]
      • Description: An array of Url Patterns (a single string is allowed)
    • blockedUrlPatterns
      • Type: String[]
      • Description: An array of Url Patterns (a single string is allowed)
  • Alias: AddMNetAppCFR

Examples

$Network | Add-MerakiNetworkApplianceContentFilteringRule -allowedUrlPatterns "xtz.com" -blockedUrlPatterns "badsite.com"

Remove-MerakiNetworkApplianceContentFilteringRules

  • Description: This is a simpler way to update the filtering rules. With this function you do not have to pull the rules before updating.

  • Parameters:

    • id:
      • Type: String
      • Mandatory: True
      • Accepts value from pipeline: True
      • Accepts value from pipeline by property name: True
      • Description: Network ID
    • allowedUrlPatterns
      • Type: String[]
      • Description: An array of Url Patterns (a single string is allowed)
    • blockedUrlPatterns
      • Type: String[]
      • Description: An array of Url Patterns (a single string is allowed)
  • Alias: RemoveMNetAppCFR

Examples

$Network | Remove-MerakiNetworkApplianceContentFilteringRule -allowedUrlPatterns "xtz.com" -blockedUrlPatterns "badsite.com"

Get-MerakiAppliancePorts

  • Description: Get port configuration for a MX Device.

  • Parameters:

    • id:
      • Type: String
      • Mandatory: True
      • Accepts value from pipeline: True
      • Accepts value from pipeline by property name: True
      • Description: Network ID
  • Alias: GMAppPorts

Get-MerakiNetworkApplianceStaticRoutes

  • Description: List the static routes for an MX or teleworker network

  • Parameters:

    • id:
      • Type: String
      • Mandatory: True
      • Accepts value from pipeline: True
      • Accepts value from pipeline by property name: True
      • Description: Network ID
  • Alias: GMNetAppRoutes

Get-MerakiNetworkApplianceVLANS

  • Description: List the VLANs for an MX network

  • Parameters:

    • id:
      • Type: String
      • Mandatory: True
      • Accepts value from pipeline: True
      • Accepts value from pipeline by property name: True
      • Description: Network ID
  • Alias: GMNetAppVLANs

Get-MerakiNetworkApplianceVLAN

  • Description: Get a specific MX VLAN

  • Parameters:

    • networkId:
      • Type: String
      • Mandatory: True
      • Accepts value from pipeline: True
      • Accepts value from pipeline by property name: True
      • Description: Network ID
    • id:
      • Type: String
      • Mandatory: True
      • Accepts value from pipeline: True
      • Accepts value from pipeline by property name: True
      • Description: MX Device ID
  • Alias: GMNetAppVLAN

Get-MerakiNetworkApplianceSiteToSiteVPN

  • Description: Return the site-to-site VPN settings of a network. Only valid for MX networks.

  • Parameters:

    • id:
      • Type: String
      • Mandatory: True
      • Accepts value from pipeline: True
      • Accepts value from pipeline by property name: True
      • Description: Network ID
  • Alias: GMNetAppSSVPN

Get-MerakiApplianceUplinkStatuses

  • Description List uplink status for Meraki MXs

  • Parameters:

    • networkId:
      • Type: String
      • Accepts value from pipeline: True
      • Accepts value from pipeline by property name: True
      • Description: Network ID
    • serial:
      • Type: String
      • Accepts value from pipeline: True
      • Accepts value from pipeline by property name: True
      • Description: MX Serial number
  • Alias: GMAppUpStat Note Parameters are optional. If omitted all MX uplinks for the organization will be returned.

Get-MerakiNetworkApplianceVpnStats

  • Description: Get site-to-site VPN Statistics for a Network

  • Parameters:

    • id:
      • Type: String
      • Mandatory: True
      • Accepts value from pipeline: True
      • Accepts value from pipeline by property name: True
      • Description: Network ID
    • perPage:
      • Type: Integer
      • Mandatory: False
      • Default: 100
      • Description: Number it items per page
    • timespan:
      • Type Integer
      • Default: 5 (days)
      • Description: Time span to retrieve data in days (Default is 5 days)
    • Summarize:
      • Type: Switch
      • Mandatory: False
      • Description: Summarize the in/out data for all Network peers.
  • Alias: GMAVpnStats

Switches

Get-MerakiSwitchRoutingInterfaces

  • Description: List layer 3 interfaces for a switch

  • Parameters:

    • serial:
      • Type: String
      • Mandatory: True
      • Accepts value from pipeline: True
      • Accepts value from pipeline by property name: True
      • Description: MS Switch serial number
  • Alias GMSWRoutInts

Get-MerakiSwitchRoutingInterface

  • Description: List Layer 3 interface for a switch

  • Parameters:

    • serial:
      • Type: String
      • Mandatory: True
      • Description: MS Switch serial number
    • interfaceId:
      • Type: String
      • Description: Interface ID
  • Alias: GMSWRoutInt

Get-MerakiSwitchRoutingInterfaceDHCP

  • Description: Return a layer 3 interface DHCP configuration for a switch

  • Parameters:

    • serial:
      • Type: String
      • Mandatory: True
      • Description: MS Switch serial number
    • interfaceId:
      • Type: String
      • Description: Interface ID
  • Alias: GMSWRoutIntDHCP

Get-MerakiSwitchRoutingStaticRoutes

  • Description: List layer 3 static routes for a switch

  • Parameters:

    • serial:
      • Type: String
      • Mandatory: True
      • Description: MS Switch serial number
  • Alias: GMSWRoutStatic

Get-MerakiNetworkSwitchLAG

  • Description: List link aggregation groups

  • Parameters:

    • id:
      • Type: String
      • Mandatory: True
      • Accepts value from pipeline: True
      • Accepts value from pipeline by property name: True
      • Description: Network ID
  • Alias: GMNetSWLag

Get-MerakiNetworkSwitchStacks

  • Description: List switch stacks for a MX network

  • Parameters:

    • id:
      • Type: String
      • Mandatory: True
      • Accepts value from pipeline: True
      • Accepts value from pipeline by property name: True
      • Description: Network ID
  • Alias: GMNetSWStacks

Get-MerakiSwitchPorts

  • Description: Get port configuration for an MS Switch

  • Parameters:

    • serial:
      • Type: String
      • Mandatory: True
      • Accepts value from pipeline: True
      • Accepts value from pipeline by property name: True
      • Description: MS switch serial number
  • Alias: GMSWPorts

Reset-MerakiSwitchPorts

  • Description: Reset MX switcvh Port(s)

  • Parameters:

    • serial:
      • Type: String
      • Mandatory: True
      • Accepts value from pipeline: True
      • Accepts value from pipeline by property name: True
      • Description: MS switch serial number
    • ports:
      • Type String[]
      • Description: Array of port numbers
  • Alias: RMSWPorts

Wireless

Get-MerakiSSIDs

  • Description: List SSIDs in an MX Network

  • Parameters:

    • id:
      • Type: String
      • Mandatory: True
      • Accepts value from pipeline: True
      • Accepts value from pipeline by property name: True
      • Description: Network ID
  • Alias: GMSSIDs

Get-MerakiSSID

  • Description List a specific SSID

  • Parameters:

    • networkId
      • Type: String
      • Mandatory: True
    • number:
      • Type: Integer
      • Mandatory: True
  • Alias: GMSSID

Get-MerakiWirelessStatus

  • Parameters:

    • serial:
      • Type: String
      • Mandatory: True
      • Accepts value from pipeline: True
      • Accepts value from pipeline by property name: True
      • Description: MR AP serial number
  • Alias: GMWirelessStat