The Meraki Community
Register or Sign in
cancel
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • About STM
STM

STM

Comes here often

Member since Jun 18, 2020

‎07-01-2020

Community Record

5
Posts
0
Kudos
0
Solutions

Badges

First 5 Posts View All
Latest Contributions by STM
  • Topics STM has Participated In
  • Latest Contributions by STM

Re: Automated password for Guest wireless user

by STM in Wireless LAN
‎06-21-2020 06:04 AM
‎06-21-2020 06:04 AM
Hi nealgs,   This is output of "change".   Change Wifi password Network Name : STM-HQ id : N_739153288842186759 Type : wireless SSID Name : GUEST_WIFI SSID# : 1 Current PSK : 73gbL#!Bym New PSK : pWD%3hc4a$ Sending Email     This is output of "display". It shows updated password.   Displaying Wifi details Network Name : STM-HQ id : N_739153288842186759 Type : wireless SSID Name : GUEST_WIFI SSID# : 1 Current PSK : pWD%3hc4a$     For SSID PSK in Meraki dashboard, it still shows very old one. But we don't need to take note that PSK right? ... View more

Re: Automated password for Guest wireless user

by STM in Wireless LAN
‎06-21-2020 05:31 AM
‎06-21-2020 05:31 AM
Hi nealgs,   I also tried and get the new PSK from email. But when I check the SSID PSK on Meraki dashboard, it display old PSK.   It should display the updated PSK, right?     Regards, ... View more

Re: Automated password for Guest wireless user

by STM in Wireless LAN
‎06-21-2020 01:51 AM
‎06-21-2020 01:51 AM
Hi nealgs,       If I add comma and run the script, it got following issue.     At C:\Users\sithu\Desktop\MerakiPSKTool.ps1:47 char:28 + "encryptionMode" = "wpa", + ~~~~~ The assignment expression is not valid. The input to an assignment operator must be an object that is able to accept assignments, such as a variable or a property. At C:\Users\sithu\Desktop\MerakiPSKTool.ps1:48 char:9 + "authMode" = "psk", + ~~~~~~~~~~ The assignment expression is not valid. The input to an assignment operator must be an object that is able to accept assignments, such as a variable or a property. At C:\Users\sithu\Desktop\MerakiPSKTool.ps1:48 char:22 + "authMode" = "psk", + ~~~~~ The assignment expression is not valid. The input to an assignment operator must be an object that is able to accept assignments, such as a variable or a property. At C:\Users\sithu\Desktop\MerakiPSKTool.ps1:49 char:3 + "psk" = $newpassword + ~~~~~ The assignment expression is not valid. The input to an assignment operator must be an object that is able to accept assignments, such as a variable or a property. + CategoryInfo : ParserError: (:) [], ParseException + FullyQualifiedErrorId : InvalidLeftHandSide         If I don't add this two parameters "encryptionMode=wpa, authMode=psk", I got following issue when I run the script with "change" switch.     Invoke-WebRequest : The remote server returned an error: (400) Bad Request. At C:\Users\sithu\Desktop\MerakiPSKTool.ps1:56 char:7 +     $r = Invoke-WebRequest $request_uri -Method:Put -Headers $header_ ... +          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~     + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException     + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand     Thank you. ... View more

Re: Automated password for Guest wireless user

by STM in Wireless LAN
‎06-19-2020 03:01 AM
‎06-19-2020 03:01 AM
Hi Nealgs,   Yes, I made necessary changes in script. I can see the SSID PSK with "Display" switch. But I cannot change the PSK. If I run with "Change" switch, this error occurs.   Following is my Script that I add required parameters.      param([string]$site="",[string]$ssid="",[string]$action="")     function sendMail([string]$txtbody) {      #SMTP server name      $smtpServer = "xxx.xxx.xxx.xxx"        #Creating a Mail object      $msg = new-object Net.Mail.MailMessage        #Creating SMTP server object      $smtp = new-object Net.Mail.SmtpClient($smtpServer)        #Email structure       $msg.From = "merakiapi@xxx.com"      $msg.To.Add("xxx@xxx.com") #$msg.To.Add("<OtherRecipientAddressHere")      $msg.subject = "New password for guest Wifi"       $msg.body = $txtbody $msg.IsBodyHTML=$true        #Sending email       $smtp.Send($msg) }   function Get-RandomCharacters($length, $characters) {      $random = 1..$length | ForEach-Object { Get-Random -Maximum $characters.length }      $private:ofs=""      return [String]$characters[$random] }   function Scramble-String([string]$inputString) {          $characterArray = $inputString.ToCharArray()        $scrambledStringArray = $characterArray | Get-Random -Count $characterArray.Length          $outputString = -join $scrambledStringArray     return $outputString  }   function updateWiFiPSK ([string]$s_id, [string]$w_id, [String]$newpassword) { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12   # PSK = New password $data = @{         "encryptionMode" = "wpa"         "authMode" = "psk" "psk" = $newpassword }   #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)             {             Write-host "Network Name : " $json[$i].name             Write-host "id           : " $json[$i].id             Write-host "Type         : " $json[$i].type               $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"="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"} -ContentType "application/json"           $z = $r | ConvertFrom-Json           for($i=0;$i -lt $z.count;$i++)             {                        If ($z[$i].name -eq $ssid)                 {                 Write-host "SSID Name    : " $z[$i].name                 Write-host "SSID#        : " $z[$i].number                  Write-host "Current PSK  : " $z[$i].psk                   $w_id = $z[$i].number                 }             }         }       return $w_id     }   function createPassword { $password = Get-RandomCharacters -length 4 -characters 'abcdefghiklmnoprstuvwxyz' $password += Get-RandomCharacters -length 2 -characters 'ABCDEFGHKLMNOPRSTUVWXYZ' $password += Get-RandomCharacters -length 2 -characters '1234567890' $password += Get-RandomCharacters -length 2 -characters '!$%&()?}][{@#+'   #Write-Host $password   return Scramble-String $password }   # setup some global static stuff $base_uri = "https://nxxx.meraki.com/api/v0/organizations/xxxxxx/" ##    E.G.   n34.meraki.com/api/v0/organizations/<OrgID>/ $networks_uri = "networks/" #Meraki API KEY $api_key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" $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 $_ }         {             "Change Wifi password"             $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")     {     # generate a new complex password     $newpassword = createPassword        $result = updateWiFiPSK $s_id $w_id $newpassword       #Write-Host $result   # build email message body and send it     if ($result.StatusCode -eq 200)         {         Write-Host "Sending Email"           $txtbody = "<html><body>"         $txtbody = $txtbody + "The new password for " + $ssid + " at " + $site + " is<br><br><b><font size=30 color=green>"         $txtbody = $txtbody + $newpassword + "</font></b>"         $txtbody = $txtbody + "<br><br>If you have any problems please contact XXX"         $txtbody = $txtbody + "<br><br>regards<br>SignoffInfo"         $txtbody = $txtbody + "</body></html>"           #Write-Host $txtbody   # send the email         sendMail $txtbody         }     else         {         Write-Host "Password change failed for " + $ssid + " at " + $site         }     }     Thanks a lot for your reply.   Regards, ... View more

Re: Automated password for Guest wireless user

by STM in Wireless LAN
‎06-18-2020 10:48 AM
‎06-18-2020 10:48 AM
I have got following error message when I try with "Change" option. "Display" option is okay. Can help me check this error?   Invoke-WebRequest : The remote server returned an error: (400) Bad Request. At C:\Users\sithu\Dropbox\AMNET\Meraki WiFi PSK Auto Generate\MerakiPSKTool.ps1:56 char:7 + $r = Invoke-WebRequest $request_uri -Method:Put -Headers $header_ ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand ... View more
Powered by Khoros
custom.footer.
  • Community Guidelines
  • Cisco Privacy
  • Khoros Privacy
  • Privacy Settings
  • Terms of Use
© 2023 Meraki