Skip to content

New-MgBetaSecurityAttackSimulationTrainingCampaign / Training campaign (preview) #2953

@marcinsamuel

Description

@marcinsamuel

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": "[email protected]"
  },
  "endUserNotificationSetting": {
    "trainingAssignment": {
      "defaultLanguage": "en",
      "[email protected]": "https://graph.microsoft.com/beta/security/attackSimulation/endUserNotifications('36fb4dc1-7c37-4b96-9096-12e6d6014fae')"
    },
    "trainingReminder": {
      "deliveryFrequency": "weekly",
      "[email protected]": "https://graph.microsoft.com/beta/security/attackSimulation/endUserNotifications('fe521249-9901-4584-a987-026a9980c58e')",
      "defaultLanguage": "en"
    },
    "notificationPreference": "microsoft",
    "settingType": "trainingSelected"
  },
  "includedAccountTarget": {
    "accountTargetEmails": [
      "[email protected]"
    ],
    "type": "addressBook"
  },
  "lastModifiedBy": {
    "email": "[email protected]"
  },
  "trainingSetting": {
    "trainingAssignmentMappings": [
      {
        "[email protected]": "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

  • OS:
    • Windows 10
    • Windows 11
  • PS:
    • 5.1
    • 7.4

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions