Working with PowerShell 2.0 and .NET using System.Net.WebRequest which returns raw JSON data in 1 long string. I need to pull the number that is listed for PhoneNumber out and assign it to a variable but can't figure out a good way to do so using PowerShell 2.0
#HTTP Request, hits the URL specified and stores the response in $result
$r = [System.Net.WebRequest]::Create("URL HERE")
$resp = $r.GetResponse()
$reqstream = $resp.GetResponseStream()
$sr = new-object System.IO.StreamReader $reqstream
$result = $sr.ReadToEnd()
write-host $result
The above request stores the response in $result as a large string like this...
{"success":1,"data":{"Username":"XXXX","FirstName":"XXXX","LastName":"XXXX","SiteName":"XXXX","PrimaryExternalHostnameWFH":"XXXX","PhoneModel":"XXXX","PhoneNumber":"1234567890","EmployeeID":"XXXX","AgentID":"XXXX","PrimaryCompanyID":"XX","PhoneSystemSiteID":"X"}}
How can I pull out just the number given for PhoneNumber and assign it to a different variable?
Aucun commentaire:
Enregistrer un commentaire