cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
23830
Views
23
Helpful
42
Replies

Meraki PowerShell Module - All Endpoints

DocNougat
Community Member

Hi Everyone,

I got a little frustrated by the lack of any official PowerShell module for Cisco's Meraki products and the existing independently developed modules only have a fraction of the available endpoints. So to remedy this issue I wrote my own. I've been working on it on and off for a few months and I've finally reached a point that I'm considering the 1.0 release. There are 644 commands in total and I've been able to test a majority of the Get commands. The others I've had less opportunity to verify, but I have tested and used a few of them in production ready scripts. I'm still working on more detailed documentation, but in its current form it's ready for other humans to start playing with it and providing feedback.

I've published it to GitHub and the official PowerShell Gallery repository so you can install manually or simply by running the install command from an elevated PowerShell window:

Install-Module Meraki

You'll need an API key from your Meraki dashboard to get started.

Check the GitHub page for more information and usage examples:
Meraki PowerShell Module on GitHub

If anyone from Cisco is watching this thread, please send me free gear to validate my module with.


I'm already using this heavily in my own environment, but I'm looking for more people to test and provide feedback.

P.S. I'm #notTheNetworkGuy, I'm an IT Operations engineer and my job is largely focused on automating our environment. Nothing I've done here couldn't also have been easily accomplished with the existing Python library, but everything else in my mostly Windows-centric world is using PowerShell, so I made this to be able to write everything in the same language.

42 Replies 42

aleabrahao
Meraki Community All-Star
Meraki Community All-Star

Maybe it will help you.

https://www.powershellgallery.com/packages?q=Tags%3A%22Meraki%22

I am not a Cisco employee. My suggestions are based on documentation of Meraki best practices and day-to-day experience.

Please, if this post was useful, leave your kudos and mark it as solved.

It was actually the existing lackluster options that caused me to create this.

Philip D'Ath
Meraki Community All-Star
Meraki Community All-Star

Well done. What a great effort.

Thanks!

Brash
Meraki Community All-Star
Meraki Community All-Star

Good to see (and welcome to the community)!
Thanks for putting in the effort, it looks great.

The lack of a decent powershell module was something I noticed early on too but I'm nowhere near proficient enough to write my own.

DarkStar1
Level 2
Level 2

@DocNougat I add this module and it looks extremely promising. I need to update a SSID across 170 networks and have been playing with the following commands but I keep getting error messages. I think there is a bug in the code or there is just not enough information to write the commands correctly on my part. Any help you can provide would be greatly appreciated.

$SSIDConfig = {"name":"TEST- Vendor 2" "enabled":"True" "authMode":"psk" "psk":"TestTest1" "encryptionMode":"wpa" "wpaEncryptionMode":"WPA3 Transition Mode" "ipAssignmentMode":"NAT Mode" "bandSelection":"Dual band operation" "lanIsolationEnabled":"False"}

$SSIDConfig = $SSIDConfig | ConvertTo-Json -Compress

Set-MerakiNetworkWirelessSSID -AuthToken "7xxxxxxxxxxxxxxxxxxxxxxx" -NetworkId "L_6xxxxxxxxxxxxxxxxxxx" -Number 2 -SSIDConfig $SSIDConfig

The first issue is that it does not like the {"name":"Test - Vendor 2" .... I have tired comas, spaces, semi-colons, as well as single quotes and double quotes, etc.

I have also tried @{"name":"TEST- Vendor 2" .....} in case it thinks it is an ARRAY. So far I cannot get past this.

Error:

At line:1 char:18
+ $SSIDConfig = {"name":"TEST - Vendor 2","enabled":"True","authMo ...
+ ~~~
Unexpected token ':"TEST - Vendor 2"' in expression or statement.

I tried the following which does not give me an error for the $SSIDConfig but does give me a message when I use the Set-MerakiNetworkWirelessSSID command.

$SSIDConfig = {name:TEST - Vendor 2,enabled:True,authMode:psk,psk:TestTest1,encryptionMode:wpa,wpaEncryptionMode:WPA3 Transition Mode,ipAssignmentMode:NAT Mode,bandSelection:Dual band operation,lanIsolationEnabled:False}

$SSIDConfig = $SSIDConfig | ConvertTo-Json -Compress

Set-MerakiNetworkWirelessSSID -AuthToken "7xxxxxxxxxxxxxxxxxxxxxxx" -NetworkId "L_6xxxxxxxxxxxxxxxxxxx" -Number 2 -SSIDConfig $SSIDConfig

Error:


The remote server returned an error: (400) Bad Request.

Any suggestions or help would be most helpful. Thanks.

Philip D'Ath
Meraki Community All-Star
Meraki Community All-Star

What happens if you use a name of "Test" (an invalid SSID - does that resolve the "Unexpected token" error?).

Thanks for the idea, however same Error:

$SSIDConfig = {"name":"Test","enabled":"True","authMode":"psk","psk":"TestTest1","encryptionMode":"wpa","wpaEncryptionMode":"WPA3 Transition Mode","ipAssignmentMode":"NAT Mode","bandSelection":"Dual band operation","lanIsolationEnabled":"False"}
At line:1 char:23
+ $SSIDConfig = {"name":"Test","enabled":"True","authMode":"psk","psk" ...
+ ~~~~~~~
Unexpected token ':"Test"' in expression or statement.
At line:1 char:30
+ $SSIDConfig = {"name":"Test","enabled":"True","authMode":"psk","psk" ...
+ ~
Missing argument in parameter list.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnexpectedToken

aleabrahao
Meraki Community All-Star
Meraki Community All-Star

The syntax is incorrect. In PowerShell, hashtables are defined using @{} and key-value pairs are separated by = and semicolons ;

I am not a Cisco employee. My suggestions are based on documentation of Meraki best practices and day-to-day experience.

Please, if this post was useful, leave your kudos and mark it as solved.

Thanks. I think I tried that and then you get prompted for more information from PS.

Yup tested it just now and I get the PS >> prompt requesting more information.

$SSIDConfig = @{"name":"Test";"enabled":"True";"authMode":"psk";"psk":"TestTest1";"encryptionMode":"wpa";"wpaEncryptionMode":"WPA3 Transition Mode";"ipAssignmentMode":"NAT Mode";"bandSelection":"Dual band operation";"lanIsolationEnabled":"False"}
>>

aleabrahao
Meraki Community All-Star
Meraki Community All-Star

Sorry for the question, but what exactly are you trying to update? Are these networks in a template?

I am not a Cisco employee. My suggestions are based on documentation of Meraki best practices and day-to-day experience.

Please, if this post was useful, leave your kudos and mark it as solved.

We have 170 Meraki Networks. I am trying to push out a standard SSID to all the sites {networks} We need all of them to have the exact same SSID. This test is just doing one network to test once I get it correct I will write the PowerShell to enumerate all the networks and update them.

aleabrahao
Meraki Community All-Star
Meraki Community All-Star

I got It. I have an example of a script that I used for my clients, but I didn't find the latest version, but I have this other one that could help.

# Define the API key
$apiKey = "<Your-API-Key>"

# Define the new SSID name
$newSSIDName = "<New-SSID-Name>"

# Define the network IDs
$networkIDs = "<Your-Network-IDs>"

# Define the headers
$headers = @{
"X-Cisco-Meraki-API-Key" = $apiKey
"Content-Type" = "application/json"
}

# Loop through each network ID
foreach ($networkID in $networkIDs) {
# Define the API endpoint
$uri = "https://api.meraki.com/api/v1/networks/$networkID/wireless/ssids/0"

# Define the body
$body = @{
"name" = $newSSIDName
} | ConvertTo-Json

# Make the PUT request
$response = Invoke-RestMethod -Uri $uri -Method Put -Body $body -Headers $headers

# Print the response
Write-Output "Response for network $networkID:"
Write-Output $response
}



I am not a Cisco employee. My suggestions are based on documentation of Meraki best practices and day-to-day experience.

Please, if this post was useful, leave your kudos and mark it as solved.

Opps forgot the = ... did that and it works but you get the error from PS

The remote server returned an error: (400) Bad Request.