Advertisement
NaterTater

NaterTater T-Mobile Arcadyan KVD21 Setting Script2

May 28th, 2023 (edited)
5,866
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.91 KB | None | 1 0
  1. #thanks to the individual contributors that helped create and update this code!
  2.  
  3. $ErrorActionPreference = 'SilentlyContinue'
  4. function token
  5. {
  6.  
  7. $Pass = Read-Host "Enter Password For The Gateway"
  8. $body = @"
  9. {
  10. "username": "admin",
  11. "password": "$Pass"
  12. }
  13. "@
  14. $login = Invoke-RestMethod -Method POST -Uri "http://192.168.12.1/TMI/v1/auth/login" -Body $body
  15. $token = $login.auth.token
  16. $global:header = @{Authorization="Bearer $token"}
  17. $Date = (Get-Date -format "hh-mm-ss")
  18. $response = Invoke-RestMethod -Uri "http://192.168.12.1/TMI/v1/network/configuration?get=ap" -headers $global:header -o .\Backup-config-$Date.txt
  19. }
  20.  
  21. function Show-Menu
  22. {
  23. param (
  24. [string]$Title = 'My Menu'
  25. )
  26. Clear-Host
  27. Write-Host "Options for Gateway"
  28. Write-Host "Press '1' to Download Config to Make Changes."
  29. Write-Host "Press '2' to Download Config to Verify Changes."
  30. Write-Host "Press '3' to Reboot Gateway."
  31. Write-Host "Press '4' to Upload Backup settings. Rename selected Backup to Backup-config.txt "
  32. Write-Host "Q: Press 'Q' to Quit."
  33. }
  34.  
  35.  
  36. function change
  37. {
  38.  
  39. $response = Invoke-RestMethod -Uri "http://192.168.12.1/TMI/v1/network/configuration?get=ap" -headers $global:header -o .\config.txt
  40.  
  41. Start-Process notepad .\config.txt -NoNewWindow -Wait
  42. $response = Invoke-RestMethod -TimeoutSec 1 -Method POST -Uri "http://192.168.12.1/TMI/v1/network/configuration?set=ap" -headers $global:header -body (Get-Content .\config.txt) -ContentType "application/json"
  43. Remove-Item -Path .\config.txt
  44. }
  45.  
  46.  
  47. function Backup
  48. {
  49.  
  50.  
  51. $response = Invoke-RestMethod -TimeoutSec 1 -Method POST -Uri "http://192.168.12.1/TMI/v1/network/configuration?set=ap" -headers $global:header -body (Get-Content .\Backup-config.txt) -ContentType "application/json"
  52.  
  53. }
  54.  
  55.  
  56. function config
  57. {
  58.  
  59. $response = Invoke-RestMethod -Uri "http://192.168.12.1/TMI/v1/network/configuration?get=ap" -headers $global:header -o .\config.txt
  60. Start-Process notepad .\config.txt -NoNewWindow -Wait
  61. Remove-Item -Path .\config.txt
  62.  
  63. }
  64.  
  65. function reboot
  66. {
  67.  
  68. $response = Invoke-RestMethod -TimeoutSec 1 -Method POST -Uri "http://192.168.12.1/TMI/v1/gateway/reset?set=reboot" -headers $global:header
  69.  
  70. }
  71.  
  72.  
  73.  
  74. function menu
  75. {
  76.  
  77.  
  78. Show-Menu -Title 'My Menu'
  79. $selection = Read-Host "Please make a selection"
  80. switch ($selection)
  81. {
  82. '1' {
  83.  
  84. 'Opening Config for changes'
  85. change
  86. 'Returning to Menu'
  87. Start-Sleep -s 1
  88. menu
  89.  
  90. } '2' {
  91.  
  92. 'Opening Config to Verify Changes'
  93. config
  94. 'Returning to Menu'
  95. Start-Sleep -s 1
  96. menu
  97.  
  98.  
  99. }'3'{
  100.  
  101. 'Rebooting Gateway'
  102. Start-Sleep -s 1
  103.  
  104. reboot
  105. return
  106.  
  107. }'4'{
  108.  
  109. 'Uploading Backup Config'
  110.  
  111. Backup
  112. 'Returning to Menu'
  113. Start-Sleep -s 1
  114. menu
  115.  
  116. } 'q' {
  117. return
  118. }
  119. }
  120.  
  121. }
  122. token
  123. menu
  124.  
  125. $response
  126.  
  127.  
  128.  
  129.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement