since the latest update my pieced together script that i put to gether using other peoples scripts has stopped working. i have tried and tried to figure out what is wrong and also tried switching to v1 api but no luck, below is a sanitized copy of my script and was really really hoping someone could help. it changes the wifi password on a scheduled basis for guest wifi. any help is very much appreciated. param([string]$site="",[string]$ssid="",[string]$action="") [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12 -bor [System.Net.SecurityProtocolType]::Tls11 # change path below for password file name $chgpw = get-content "C:\Users\removedusernameforsecurity\Desktop\update meraki wifi passwords\password.txt" function updateWiFiPSK ([string]$s_id, [string]$w_id, [string]$chgpw) { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 # PSK = New password $data = @{ "psk" = $chgpw } #Convert data to Json format $jbody = ConvertTo-Json -InputObject $data #Combine base URL and ssid $request_uri = $base_uri + $networks_uri + $s_id + "/ssids/" + $w_id $r = Invoke-WebRequest $request_uri -Method:Put -Headers $header_org -Body $jbody return $r } function Get-SiteID { #get site id $request_uri = $base_uri + $networks_uri $r = Invoke-WebRequest $request_uri -Method:Get -Headers $header_org $json = $r | ConvertFrom-Json for($i=0;$i -lt $json.count;$i++) { if ($site -eq $json[$i].name) { $s_id = $json[$i].id } } return $s_id } function Get-WiFiSSID ([string]$s_id) { #get wifi network ID from site requested if ($s_id -ne "") { $request_uri = $base_uri + $networks_uri + $s_id + "/ssids/" $r = Invoke-WebRequest $request_uri -Method:Get -Headers @{"X-Cisco-Meraki-API-Key"="removedkeyforsecuritytopostonline"} -ContentType "application/json" $z = $r | ConvertFrom-Json for($i=0;$i -lt $z.count;$i++) { If ($z[$i].name -eq $ssid) { write-output $z[$i].psk > c:\trash.txt $w_id = $z[$i].number } } } return $w_id } # setup some global static stuff $base_uri = "https://editedforseurity.meraki.com/api/v0/organizations/ideditedforecurity/" ## E.G. n34.meraki.com/api/v0/organizations/<OrgID>/ $networks_uri = "networks/" #Meraki API KEY $api_key = "keyeditedforsecurity" $header_org = @{"X-Cisco-Meraki-API-KEY" = $api_key;"Content-Type" = 'application/json'} $s_id = "" $w_id = "" $mode = "" If ($site -eq "" -or $ssid -eq "") { Write-Host "MerakiPSKTool - (c) 2019" Write-Host "" Write-Host "Site/SSID parameter is missing" Write-Host "Usage: MerakiPSKTool.ps1 -site <sitename> -ssid <ssidName> -action [Change | Display]" Write-Host "" exit } # if action not passed or is blank, set default mode to Display if ($action -eq "") { $action = "Display" } switch ($action) { {@("Display", "display") -contains $_ } { "Displaying Wifi details" $mode = "display" } {@("Change", "change") -contains $_ } { $mode = "change" } default { "MerakiPSKTool.ps1" } } # get ID of the site passed in params (set a default value if no site passed) $s_id = Get-SiteID If ($s_id -ne "") { # get id of Wifi network that password is to be changed for $w_id = Get-WifiSSID($s_id) #Write-Host "Site ID : " $s_id " | Wifi #: " $w_id } if ($mode -eq "change") { $result = updateWiFiPSK $s_id $w_id $chgpw } else { Write-Host "Password change failed for " + $ssid + " at " + $site }
... View more