Powershell with RestAPI to obtain CSV output of computer details

I need a solution

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… -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 -Headers $header


The content of $result comes out looking like this…

{“content”:[{“group”:{“id”:”A9C5F6A8C0A802681CDA41B0DD225D79″,”name”:”My Company\Default Group”,”f
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?




  • No Related Posts

Leave a Reply