microsoftgraph / msgraph-sdk-powershell

Powershell SDK for Microsoft Graph
https://www.powershellgallery.com/packages/Microsoft.Graph
Other
691 stars 165 forks source link

New-MgBetaSecurityAttackSimulationTrainingCampaign / Training campaign (preview) #2953

Closed marcinsamuel closed 1 week ago

marcinsamuel commented 2 weeks ago

Describe the bug

I try to create a new training campaign and use for that New-MgBetaSecurityAttackSimulationTrainingCampaign cmdlet. Morover I tested Microsoft Graph REST, POST request directly from PowerShell (Invoke-WebRequest) and Microsoft Graph Explorer. Sadly in every case I got the same error.

{"Code":400,"Message":"AssignedTo object missing in trainingAssignmentMappings[0]",
"Target":null,"Details":null,"InnerError":null}  Status: 400 (BadRequest) ErrorCode: UnknownError}

Expected behavior

Method returns a 202 Accepted and new training campaign is created on https://security.microsoft.com/attacksimulator

How to reproduce

Execute a code sample from an official documentation

SDK Version

2.23.0 Microsoft.Graph.Beta.Security

Latest version known to work for scenario above?

No response

Known Workarounds

No response

Debug output

New-MgBetaSecurityAttackSimulationTrainingCampaign -BodyParameter $params -Debug ``` DEBUG: [CmdletBeginProcessing]: - New-MgBetaSecurityAttackSimulationTrainingCampaign begin processing with parameterSet 'Create'. DEBUG: [Authentication]: - AuthType: 'AppOnly', TokenCredentialType: 'ClientSecret', ContextScope: 'Process', AppName: 'DEV_ATTACK_SIMULATION_TRAINING'. DEBUG: [Authentication]: - Scopes: [User.Read.All, AttackSimulation.ReadWrite.All]. Confirm Are you sure you want to perform this action? Performing the operation "New-MgBetaSecurityAttackSimulationTrainingCampaign_Create" on target "Call remote 'POST /security/attackSimulation/trainingCampaigns' operation". [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): y DEBUG: ============================ HTTP REQUEST ============================ HTTP Method: POST Absolute Uri: https://graph.microsoft.com/beta/security/attackSimulation/trainingCampaigns Headers: FeatureFlag : 00000043 Cache-Control : no-store, no-cache User-Agent : Mozilla/5.0,(Windows NT 10.0; Microsoft Windows 10.0.19045; en-US),PowerShell/2024.2.2 Accept-Encoding : gzip SdkVersion : graph-powershell-beta/2.23.0 client-request-id : 9721a794-0b07-4363-b781-6f8521d0c942 Body: { "description": "Graph Training Campaign Description", "displayName": "Graph Training Campaign", "campaignSchedule": { "completionDateTime": "2024-02-18T07:59:44Z", "launchDateTime": "2024-02-15T07:59:44Z", "status": "Scheduled" }, "createdBy": { "email": "john@contoso.com" }, "endUserNotificationSetting": { "trainingAssignment": { "defaultLanguage": "en", "endUserNotification@odata.bind": "https://graph.microsoft.com/beta/security/attackSimulation/endUserNotifications('36fb4dc1-7c37-4b96-9096-12e6d6014fae')" }, "trainingReminder": { "deliveryFrequency": "weekly", "endUserNotification@odata.bind": "https://graph.microsoft.com/beta/security/attackSimulation/endUserNotifications('fe521249-9901-4584-a987-026a9980c58e')", "defaultLanguage": "en" }, "notificationPreference": "microsoft", "settingType": "trainingSelected" }, "includedAccountTarget": { "accountTargetEmails": [ "john@contoso.com" ], "type": "addressBook" }, "lastModifiedBy": { "email": "john@contoso.com" }, "trainingSetting": { "trainingAssignmentMappings": [ { "training@odata.bind": "https://graph.microsoft.com/beta/security/attackSimulation/trainings('40454905-dc26-4f36-b854-3042a5362cb3')", "assignedTo": [ "allUsers" ] } ], "settingType": "microsoftCustom" } } DEBUG: ============================ HTTP RESPONSE ============================ Status Code: BadRequest Headers: Vary : Accept-Encoding Strict-Transport-Security : max-age=31536000 request-id : 7efc3295-e18b-4a03-adde-e06cfe456da1 client-request-id : 9721a794-0b07-4363-b781-6f8521d0c942 x-ms-ags-diagnostic : {"ServerInfo":{"DataCenter":"Switzerland North","Slice":"E","Ring":"3","ScaleUnit":"001","RoleInstance":"ZRH2EPF000000E0"}} Date : Wed, 11 Sep 2024 16:52:03 GMT Body: { "error": { "code": "UnknownError", "message": "{\"Code\":400,\"Message\":\"AssignedTo object missing in trainingAssignmentMappings[0]\",\"Target\":null,\"Details\":null,\"InnerError\":null}", "innerError": { "date": "2024-09-11T16:52:04", "request-id": "7efc3295-e18b-4a03-adde-e06cfe456da1", "client-request-id": "9721a794-0b07-4363-b781-6f8521d0c942" } } } New-MgBetaSecurityAttackSimulationTrainingCampaign_Create: C:\exchange\newCampaign.ps1:63:1 Line | 63 | New-MgBetaSecurityAttackSimulationTrainingCampaign -BodyParameter $pa … | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | {"Code":400,"Message":"AssignedTo object missing in trainingAssignmentMappings[0]","Target":null,"Details":null,"InnerError":null} Status: 400 (BadRequest) ErrorCode: | UnknownError Date: 2024-09-11T16:52:04 Headers: Vary : Accept-Encoding Strict-Transport-Security : max-age=31536000 request-id | : 7efc3295-e18b-4a03-adde-e06cfe456da1 client-request-id : 9721a794-0b07-4363-b781-6f8521d0c942 x-ms-ags-diagnostic : | {"ServerInfo":{"DataCenter":"Switzerland North","Slice":"E","Ring":"3","ScaleUnit":"001","RoleInstance":"ZRH2EPF000000E0"}} Date : Wed, 11 Sep 2024 | 16:52:03 GMT DEBUG: [CmdletEndProcessing]: - New-MgBetaSecurityAttackSimulationTrainingCampaign end processing. ```

Configuration

Other information

I am not 100% confident when POST call has stopped working but I would guess mid/end August 2024. I would appreciate if you could contact Microsoft Graph Beta development team and validate changes for an /security/attackSimulation/trainingCampaigns endpoint introduced in last 30 days.

timayabi2020 commented 1 week ago

@marcinsamuel thank you for raising this issue. However, for API related issues/questions we are not best placed to give an answer. Kindly raise an issue here https://developer.microsoft.com/en-us/graph/support so that the API owner can respond to it. Also see refer to the API reliability and support guide here https://learn.microsoft.com/en-us/graph/best-practices-concept#reliability-and-support