Reputation: 11
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = { $true }
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls -bor [Net.SecurityProtocolType]::Tls11 -bor [Net.SecurityProtocolType]::Tls12
Invoke-WebRequest -Uri 'https://10.45.210.143/admin/advanced/Phone.json?request'
$url = "https://10.45.210.143/admin/advanced/Phone.json?request"
$jsonData = Invoke-RestMethod -Uri $url -Method GET -UseBasicParsing
# Find the entry with "name": "PSK 1" and extract the "value"
$psk1Value = $jsonData | Where-Object { $_.name -eq "PSK 1" } | Select-Object -ExpandProperty value
# Check if the value was found and display it
if ($psk1Value) {
Write-Host "The value for 'PSK 1' is: $psk1Value"
}
returns
Invoke-WebRequest : The underlying connection was closed: An unexpected error occurred on a send.
At line:4 char:1
+ Invoke-WebRequest -Uri 'https://10.45.210.143/admin/advanced/Phone.js ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
Invoke-RestMethod : The underlying connection was closed: An unexpected error occurred on a send.
At line:6 char:13
+ $jsonData = Invoke-RestMethod -Uri $url -Method GET -UseBasicParsing
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
Trying to parse java data to render the content relevant to "PSK 1" example java from json-
"line": "one",
"type": 1,
"v": "string",
"min": 0,
"max": 511,
"value": "fnc=xml;url=https://usea.dm.sdg.teams.microsoft.com/device/logout.php/mmiiaacc/007686ce82361728055596pI6ZuvWzqw80xZNnQw9z/lang_en/;vid=n;nme=Sign Out",
"name": "PSK 1",
"index": 6097,
"tab": 6
the URL in "value" is what i'm trying to fetch.
Upvotes: 0
Views: 47