Hi - I'm trying to use powershell to query the SEPMs for information on computers protected by SEP in our environment. I can get the script to authenticate and retrieve information using the sample script but i'm now stuck at figuring out how to parse the results.
This is what i have so far:
--------------------------------------------
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = { $True }
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;
#match these paramters with the post requests for the api type listed https://SEPM_IP:8446/sepm/restapidocs.html
$cred= @{
username = "UserID"
password = "Password"
domain = ""
}
#converts $cred array to json to send to the SEPM
$auth = $cred | ConvertTo-Json
$authrequest = Invoke-RestMethod -Uri https://192.168.2.104:8446/sepm/api/v1/identity/au... -Method Post -Body $auth -ContentType 'application/json'
#access token from SEPM Authentication script
$access_token = $authrequest.token
#format HTTP header
$header =@{Authorization='Bearer '+$access_token}
$result = Invoke-RestMethod -Uri https://192.168.2.104:8446/sepm/api/v1/computers -Headers $header
--------------------------------------
The content of $result comes out looking like this...
{"content":[{"group":{"id":"A9C5F6A8C0A802681CDA41B0DD225D79","name":"My Company\\Default Group","f
ullPathName":null,"domain":{"id":"5595B9D6C0A8026862FF00463BD85216","name":"Default"},"externalRefe
renceId":null,"source":null},"ipAddresses":["192.168.2.111"],"macAddresses":["00-0C-29-7C-8C-55"],"
gateways":["192.168.2.1","0.0.0.0","0.0.0.0","0.0.0.0"],"subnetMasks":["255.255.255.0"],"dnsServers
":["192.168.2.100","0.0.0.0"],"winServers":["0.0.0.0","0.0.0.0"],"description":"","computerName":"D
LPEndpoint","logonUserName":"admin","domainOrWorkgroup":"test.ads","computerDescription":"","proces
sorType":"Intel64 Family 6 Model 62 Stepping 4","processorClock":2800,"physicalCpus":2,"logicalCpus
It appears to be a system object with no properties.... I'm having no luck parsing the data. Anybody have any insight on how to do this?
-Steve