11-02-2023 08:54 AM
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 MerakiYou'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.
11-02-2023 10:01 AM
Maybe it will help you.
https://www.powershellgallery.com/packages?q=Tags%3A%22Meraki%22
11-02-2023 10:16 AM
It was actually the existing lackluster options that caused me to create this.
11-02-2023 11:16 AM
Well done. What a great effort.
11-02-2023 11:19 AM
Thanks!
11-02-2023 03:10 PM
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.
01-16-2024 01:11 PM
@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.
01-16-2024 01:27 PM
What happens if you use a name of "Test" (an invalid SSID - does that resolve the "Unexpected token" error?).
01-17-2024 09:23 AM
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
01-17-2024 09:27 AM
The syntax is incorrect. In PowerShell, hashtables are defined using @{} and key-value pairs are separated by = and semicolons ;
01-17-2024 10:44 AM
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"}
>>
01-17-2024 10:51 AM
Sorry for the question, but what exactly are you trying to update? Are these networks in a template?
01-17-2024 12:22 PM
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.
01-17-2024 12:29 PM
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
}
01-17-2024 10:47 AM
Opps forgot the = ... did that and it works but you get the error from PS
The remote server returned an error: (400) Bad Request.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide