- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Help with Meraki API and Powershell
I am having an issue using "Invoke-RestMethod" for Powershell to pull the clients (devices) list. I have setup the API and I am able to get some information like the Admins or the Network ID, Org ID, etc. I just can't seem to figure out how to pull my devices. I have looked at the documentation over and over and it is not working. I end up getting an Error 400: Bad request.
Here is the documentation I followed to Get Clients: https://developer.cisco.com/meraki/api-v1/#!get-network-clients
Here is my Powershell script (scrubbed). Sorry, they don't have a code button for Powershell:
$APIKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
$orgid = "XXXXX"
$networkid = "N_XXXXXXXXXXXXXXXXXXXXXXXX"
$headers = @{
"Content-Type" = "application/json"
"Accept" = "application/json"
"X-Cisco-Meraki-API-Key" = $APIKey
}
Invoke-RestMethod -Method Get -Uri "https://api.meraki.com/api/v1/networks/$($networkid)/clients" -Headers $Headers
That is what I am thinking (per the documentation) should work. I am not sure where I am going wrong. I have Systems Manager only and I have devices that have been added to it. I would like that list.
Solved! Go to solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I actually got it. I just needed to add "/sm/devices" and that worked
Invoke-RestMethod -Method Get -Uri "https://api.meraki.com/api/v1/networks/$($networkid)/sm/devices"
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That code runs just fine in a non-SM network so that endpoint is likely not meant for SM, and what you are actually looking for may be one of these
https://developer.cisco.com/meraki/api-v1/#!get-network-sm-devices
https://developer.cisco.com/meraki/api-v1/#!get-network-sm-users
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Exactly! If you want SM devices that's slightly different from network clients.
Get Network Clients
Operation Id:getNetworkClients
Description:List the clients that have used this network in the timespan
Get Network Sm Devices
Operation Id:getNetworkSmDevices
Description:List the devices enrolled in an SM network with various specified fields and filters
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I actually got it. I just needed to add "/sm/devices" and that worked
Invoke-RestMethod -Method Get -Uri "https://api.meraki.com/api/v1/networks/$($networkid)/sm/devices"
Thanks!
