Description
Describe the bug
I am trying to create a new user using Microsoft Graph. This was working in versions prior to 2.25 unfortunately I didn't take note of the working module version before removing it.
When I attempt to create a new user I get: New-MgUser_CreateExpanded: A password must be specified to create a new user.
Expected behavior
User is created successfully. It was working previously but when I passed the script to a new colleague, they said it didn't work. Updating to the latest version of Microsoft.Graph broke it for me as well.
How to reproduce
New-MgUser -AccountEnabled -DisplayName "John_doe" -GivenName "John" -Surname "Doe" -UserPrincipalName "John_Doe@domain.com" -MailNickname "John_Doe" -OfficeLocation "123456" -PasswordProfile @{Password="BananaSam1234!!"; ForceChangePasswordNextSignIn=$true}
SDK Version
2.27.0
Latest version known to work for scenario above?
No response
Known Workarounds
Unknown
Debug output
Click to expand log
```VERBOSE: Performing the operation "New-MgUser_CreateExpanded" on target "Call remote 'POST /users' operation".
New-MgUser_CreateExpanded: A password must be specified to create a new user.
Status: 400 (BadRequest)
ErrorCode: Request_BadRequest
Date: 2025-05-02T23:11:03
Headers:
Cache-Control : no-cache
Vary : Accept-Encoding
Strict-Transport-Security : max-age=31536000
request-id : 45d21c5d-e766-4b39-8e31-80c7658524a8
client-request-id : d6f206f9-71f8-4728-a24b-c7ab0591a0c0
x-ms-ags-diagnostic : {"ServerInfo":{"DataCenter":"West US 2","Slice":"E","Ring":"4","ScaleUnit":"005","RoleInstance":"MWH0EPF0009A7D1"}}
x-ms-resource-unit : 1
Date : Fri, 02 May 2025 23:11:03 GMT
</details>
### Configuration
- OS: Windows 11 Enterprise 24H2
-Powershell Version:
Name Value
---- -----
PSVersion 7.4.7
PSEdition Core
GitCommitId 7.4.7
OS Microsoft Windows 10.0.26100
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
-Module:
get-installedmodule | where {$_.Name -like "Microsoft.Graph"}
Version Name Repository Description
------- ---- ---------- -----------
2.19.0 Microsoft.Graph PSGallery Microsoft Graph PowerShell module
### Other information
_No response_