哪一种特性使得一个PPOST机构到/v1.0/user?
我对以微软图号为名的具有突出特征的生成用户有问题。
我使用以下机构:
{
"accountEnabled":false,
"displayName":"ADM Joost Müller",
"userprincipalname":"[email protected]",
"mailNickname":"admjmuller",
"passwordProfile":{
"forceChangePasswordNextSignIn":true,
"forceChangePasswordNextSignInWithMfa":true,
"password":"Randompasswordgenerated"
}
}
在我向上面有色人种的人打电话给/v1.0/用户时,我收到了以下反对意见:
@odata.context : https://graph.microsoft.com/v1.0/$metadata#users/$entity
id : xxxxxxxx-xxxx-xxxx-xxxx-a72a188e6d9a
businessPhones : {}
displayName : ADM Joost M�ller
givenName :
jobTitle :
mail :
mobilePhone :
officeLocation :
preferredLanguage :
surname :
userPrincipalName : [email protected]
Note the � in the displayname. This is NOT a display problem in Powershell, the Entra ID blade in the Azure portal also shows this character. I ve already tried to forcibly convert the JSON to UTF-8:
$enc = [System.Text.Encoding]::UTF8
$jsonutf8 = $enc.getstring($enc.getbytes($json))
但这并没有解决问题。
我尝试了各种搜索术语,但找不到任何东西可以找到解决办法。 这可能是微不足道的,但如果是,使用错误搜索术语的Im。
实际代码:
function Encode {
Param(
[string]$text
)
$enc = [System.Text.Encoding]::Utf8
return $enc.getstring($enc.getbytes($text))
}
function Invoke-GraphPost {
[cmdletbinding()]
Param(
[parameter(Mandatory = $true)][string]$API,
[parameter(Mandatory = $true)][string]$AccessToken,
[parameter(Mandatory = $true)]$body,
[parameter(Mandatory = $false)][string]$Apiversion = "v1.0"
)
$header = @{
Authorization = ("Bearer {0}" -f $AccessToken)
Content-Type = application/json; charset=utf-8
}
$bodyjson = Encode(ConvertTo-Json -InputObject $body -Compress)
$URI = Encode(("https://graph.microsoft.com/{0}/{1}" -f $Apiversion, $API))
try {
$result = Invoke-RestMethod -Uri $URI -Method Post -Body $bodyjson -Headers $header
}
catch {
$FailMessage = ("Unable to create graph POST request {0} with body {1}" -f $URI, $bodyjson)
$module.failjson($FailMessage)
}
return $result
}
$password = [System.Web.Security.Membership]::GeneratePassword(12, 4)
$upnbase = New-EntraUserName -NameFormat "$adminprefix$format" -Voornaam $User.Roepnaam -Infix $User.Voorv_gebnaam -Achternaam $User.Geboortenaam -Domainname $admindomain
$body = @{
accountEnabled = $false
displayName = ("ADM {0} {1}" -f $User.Roepnaam.Trim(), $User.Volledige_achternaam.Trim())
mailNickname = $upnbase
userprincipalname = ("{0}@{1}" -f $upnbase, $admindomain)
passwordProfile = @{
forceChangePasswordNextSignIn = $true
forceChangePasswordNextSignInWithMfa = $true
password = $password
}
}
$newuser = Invoke-GraphPost -API users -AccessToken $token.access_token -body $body
Joost