Skip to content

New-MgGroup with -BodyParameter drops parameters #3308

Open
@archoversight

Description

@archoversight

Describe the bug

I am trying to pass a dictionary (or hash map or whatever it is called in Powershell) to New-MgGroup with the body parameters to create the group. But it is failing.

Expected behavior

New group is created

How to reproduce

$GroupOptions = @{
  DisplayName     = "RandomTestGroup"
  Description     = "This is a random group"
  MailEnabled     = $false
  MailNickname    = -join ((48..57) + (97..122) | Get-Random -Count 32 | % {[char]$_})
  SecurityEnabled = $true
}
New-MgGroup -BodyParameter $GroupOptions -Debug

It seems to have completely dropped everything but mailEnabled and securityEnabled.

SDK Version

2.27.0

Latest version known to work for scenario above?

2.25.0

Known Workarounds

None

Debug output

Click to expand log
DEBUG: [CmdletBeginProcessing]: - New-MgGroup begin processing with parameterSet 'Create'.
DEBUG: [Authentication]: - AuthType: 'Delegated', TokenCredentialType: 'InteractiveBrowser', ContextScope: 'CurrentUser', AppName: 'Microsoft Graph PowerShell'.
DEBUG: [Authentication]: - Scopes: [Directory.ReadWrite.All, Group.ReadWrite.All, GroupMember.ReadWrite.All, openid, profile, User.ReadWrite.All, email].

Confirm
Are you sure you want to perform this action?
Performing the operation "New-MgGroup_Create" on target "Call remote 'POST /groups' 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.us/v1.0/groups

Headers:
FeatureFlag                   : 00000003
Cache-Control                 : no-store, no-cache
User-Agent                    : Mozilla/5.0,(Macintosh; Darwin 24.4.0 Darwin Kernel Version 24.4.0: Fri Apr 11 18:33:39 PDT 2025; root:xnu-11417.101.15~117/RELEASE_ARM64_T6020; en-US),PowerShell/7.5.1
SdkVersion                    : graph-powershell/2.27.0
client-request-id             : a9d10562-5483-436c-a0ae-7ea651d095aa
Accept-Encoding               : gzip,deflate,b

Body:
{
  "mailEnabled": false,
  "securityEnabled": true
}


DEBUG: ============================ HTTP RESPONSE ============================

Status Code:
BadRequest

Headers:
Cache-Control                 : no-cache
Vary                          : Accept-Encoding
Strict-Transport-Security     : max-age=31536000
request-id                    : a784386f-f47e-42c5-8985-7130c72abf33
client-request-id             : a9d10562-5483-436c-a0ae-7ea651d095aa
x-ms-ags-diagnostic           : {"ServerInfo":{"DataCenter":"USGov Texas","Slice":"E","Ring":"4","ScaleUnit":"000","RoleInstance":"SN5NEPF0000319E"}}
Date                          : Mon, 05 May 2025 05:15:08 GM

Body:
{
  "error": {
    "code": "Request_BadRequest",
    "message": "A value is required for property 'displayName' of resource 'Group'.",
    "innerError": {
      "date": "2025-05-05T05:15:09",
      "request-id": "a784386f-f47e-42c5-8985-7130c72abf33",
      "client-request-id": "a9d10562-5483-436c-a0ae-7ea651d095aa"
    }
  }
}


New-MgGroup_Create: A value is required for property 'displayName' of resource 'Group'.

Status: 400 (BadRequest)
ErrorCode: Request_BadRequest
Date: 2025-05-05T05:15:09

Headers:
Cache-Control                 : no-cache
Vary                          : Accept-Encoding
Strict-Transport-Security     : max-age=31536000
request-id                    : a784386f-f47e-42c5-8985-7130c72abf33
client-request-id             : a9d10562-5483-436c-a0ae-7ea651d095aa
x-ms-ags-diagnostic           : {"ServerInfo":{"DataCenter":"USGov Texas","Slice":"E","Ring":"4","ScaleUnit":"000","RoleInstance":"SN5NEPF0000319E"}}
Date                          : Mon, 05 May 2025 05:15:08 GM


  Recommendation: See service error codes: https://learn.microsoft.com/graph/errors
DEBUG: [CmdletEndProcessing]: - New-MgGroup end processing.

Configuration

Name Value


PSVersion 7.5.1
PSEdition Core
GitCommitId 7.5.1
OS Darwin 24.4.0 Darwin Kernel Version 24.4.0: Fri Apr 11 18:33:39 PDT 2025; root:xnu-11417.101.15~117/RELEASE_ARM64_T6020
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0

Other information

This change was made to no longer drop true/false, but I have no idea if this now dropped everything else instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status:waiting-for-triageAn issue that is yet to be reviewed or assignedtype:bugA broken experience

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions