Endpoint Protection

 View Only
  • 1.  Invoke-RestMethod to interact with SEPM Groups

    Posted Jan 22, 2018 08:34 AM
    I'm trying API Rest method with Symantec EndPoint Manager 14 (14.0.3876.1100)
     
    [System.Net.ServicePointManager]::ServerCertificateValidationCallback = { $True }
    [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;
     
    $cred= @{
    username = "myaccount"
    password = "mypassword"
    domain = ""
    }
    #converts $cred array to json to send to the SEPM
    $auth = $cred | ConvertTo-Json
    $Authent=Invoke-RestMethod -Uri https://mySEPM:8446/sepm/api/v1/identity/authenticate -Method Post -Body $auth -ContentType 'application/json'
    $access_token = $Authent.Token
     
    #Lists All groups
    Invoke-RestMethod -Method Get -Uri https://mySEPM:8446/sepm/api/v1/groups -Headers @{Authorization='Bearer '+$access_token}
    #Creates NewGroup
    Invoke-RestMethod -Method Post -Uri https://mySEPM:8446/sepm/api/v1/groups -ContentType "application/json" -Headers @{Authorization='Bearer '+$access_token} -Body @{Groupid = "E7CE611599EF43D34050E441973EE6A7";Name = "NewGroup";Description = "NewGroup_description";inherits = "True"}
     
     
    Method Get returns an array with properties of each groups (ID, name, description, ....)
     
    I want to create a new group "NewGroup" under a group with ID "E7CE611599EF43D34050E441973EE6A7"
    Method Post returns an error 500
     
    Invoke-RestMethod : The remote server returned an error: (500) Internal Server Error.
    + Invoke-RestMethod -Method Post -Uri https://mySEPM:84 ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
        + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
     
    I think there is an error in body section.
    Someone knows the good syntax for this ?
     
    Thank you in advance.


  • 2.  RE: Invoke-RestMethod to interact with SEPM Groups
    Best Answer

    Posted Mar 09, 2018 10:40 PM

    the post query is incorrect, the GroupID should be in the Path. I have this script working, do let me know if you are still facing any issue.



  • 3.  RE: Invoke-RestMethod to interact with SEPM Groups

    Posted Mar 19, 2018 08:49 AM

    Hi NL59,

    Sent you a PM with the working cmd, please check and confirm