Powershell to change SSID via API

Zedster1974
Conversationalist

Powershell to change SSID via API

Afternoon All

Up until yesterday, the script below (adjusted to project my API & SIte only) worked to generate a new password for one of our SSID's and change it via the API.

 

Set-ExecutionPolicy Bypass -scope Process -Force
 
#Install-Module -Name PSSharedGoods -RequiredVersion 0.0.155
 
#Meraki API KEY
$api_key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
#Meraki Network URL
$network_id = "L_xxxxxxxxxxxxxxxxx"
#Base API URL
$api = @{
    "endpoint" = 'https://api.meraki.com/api/v1'
}
#API URL for SSID PSK Change XXX
$api_put = @{
        "endpoint" = 'https://api.meraki.com/api/v1'
}
 
# Word list  
$words = @('rabbit', 'peccary', 'colt', 'anteater',  
    'meerkat', 'eagle', 'owl', 'cow', 'turtle', 'bull',  
    'baselisk', 'snake', 'lizzard', 'panda', 'bear', 'pig',  
    'lion', 'tiger', 'bunny', 'wolf', 'deer', 'pronghorn',  
    'fish', 'rabbit', 'gorilla', 'puma', 'mustang', 'sheep',  
    'wolverine', 'hyena', 'beaver', 'rooster', 'ox', 'frog'  
)  
# Definition of funtion named "Create-Words"  
Function Create-Words {  
    $word1 = "ABC"
    $word2 = Get-Random -InputObject $words  # get second random word from word list
    $word3 = Get-RandomCharacters -length 1 -characters 'ABCDEFGHKLMNOPRSTUVWXYZ'
    $word4 = Get-RandomCharacters -length 1 -characters 'abcdefghiklmnoprstuvwxyz'
$word5 = Get-RandomCharacters -length 2 -characters '1234567890'
$word6 = Get-RandomCharacters -length 1 -characters '!$%&()?}][{@#+'
    $script:newWord = "$word1$word2$word3$word4$word5$word6" # combine word1 with word2 / delimiter = "-""  
}  
  
$newWord =""
 
# Execution of function "Create-Words"  
Create-Words
  
# Output of new generated word in script  
$newWord 
 
$header_org = @{
    "X-Cisco-Meraki-API-Key" = $api_key
    "Content-Type" = 'application/json'
}
# PSK = New password
 
$data = @{
    "psk" = $newWord
}
#Convert data to Json format
$jbody = ConvertTo-Json -InputObject $data
#URL Network_ID and SSID number
$api.ssid = "/networks/$network_id/wireless/ssids/6"
#Combine base api_put URL and $api.ssid
$Merakiuri = $api_put.endpoint + $api.ssid
#Invoke-RestMethod -Method Put -Uri $Merakiuri -Headers $header_org -Body $jbody | Out-Null
 
 

Not sure what has changed, but today it's not working.  No error messages are coming up - it just doesn't do anything.

 

 

 

Does anyone have any ideas or suggestions?

3 Replies 3
Zedster1974
Conversationalist

As an update to this, on checking the Meraki logs themselves, it's showing that the powershell script is running and connecting but not updating

"psk": "************* (value did not change)",

AMP
Meraki Employee
Meraki Employee

You can start with running this in postman itself without the script. Run the API that changes SSID password and manually enter a value yourself and run it. You can verify if theres anything wrong on the Meraki side of things. As long as that works you can narrow it down to something in the script. 
I would also say add a line to print exactly what your sending to the API and make sure that looks good too

Knowledge is power
travisw
New here

Just wanting to include in this conversation that our team is having issues changing the PSK for a few different networks currently using the new version of the Meraki Dashboard. The old version of the dashboard is still working fine. Not sure if this may be a related issue, but definitely seems like something on the backend changing/breaking. 

Edit: Want to add that this also started occurring today. We've been doing it for the past >year without issues.

Get notified when there are additional replies to this discussion.