Microsoft graph api 使用Microsoft Graph使用addpassword方法更新应用程序密码凭据

Microsoft graph api 使用Microsoft Graph使用addpassword方法更新应用程序密码凭据,microsoft-graph-api,Microsoft Graph Api,我正在更改更新应用程序密码凭据(特别是keyId、secretText和Hint)的Powershell脚本,与以前使用的修补程序相同,但现在已根据以下更改: 然而,当我使用POST时,我似乎无法再更新KeyId、secretText和Hint,这将继续与修补程序一起工作,但希望在这开始使用之前更新我的代码,您能提供帮助吗 该代码目前仍然有效: $jsonData = ' { "passwordCredentials": [ { "customKeyIdentifier": null,

我正在更改更新应用程序密码凭据(特别是keyId、secretText和Hint)的Powershell脚本,与以前使用的修补程序相同,但现在已根据以下更改:

然而,当我使用POST时,我似乎无法再更新KeyId、secretText和Hint,这将继续与修补程序一起工作,但希望在这开始使用之前更新我的代码,您能提供帮助吗

该代码目前仍然有效:

$jsonData = '
{
 "passwordCredentials": [
  {
  "customKeyIdentifier": null,
  "endDateTime": "2119-05-01T10:18:33.4995826Z",
  "keyId": "'+ $($guid) +'",
  "startDateTime": "2019-05-01T10:18:33.4995826Z",
  "secretText": "'+ $($Password.Password) +'",
  "hint": "'+ $($Passwordhint) +'"
  }
 ]
}'

#Specify the URI to call and method
$uri = "https://graph.microsoft.com/beta/applications/$ID/"
$method = "PATCH"
Invoke-WebRequest -Method $method -Uri $uri -ContentType "application/json" -Body $jsonData -Headers @{Authorization = "$($global:authtoken.authorization)"} -ErrorAction Stop | Out-Null
以下内容不会发布,但会创建一个没有提供任何信息的密码,并且不会按预期更新应用程序的passwordCredentials:

#Populate JSON data for the application
$jsonData = '
{
 "passwordCredentials": [
  {
  "customKeyIdentifier": null,
  "endDateTime": "2119-05-01T10:18:33.4995826Z",
  "keyId": "'+ $($guid) +'",
  "startDateTime": "2019-05-01T10:18:33.4995826Z",
  "secretText": "'+ $($Password.Password) +'",
  "hint": "'+ $($Passwordhint) +'"
  }
 ]
}'

#Specify the URI to call and method
$uri = "https://graph.microsoft.com/beta/applications/$ID/addPassword"
$method = "POST"
Invoke-WebRequest -Method $method -Uri $uri -ContentType "application/json" -Body $jsonData -Headers @{Authorization = "$($global:authtoken.authorization)"} -ErrorAction Stop | Out-Null

似乎来自的
addPassword
操作有一个包装的
passwordCredential
作为参数:

...
<Action Name="addPassword" IsBound="true">
<Parameter Name="bindingParameter" Type="microsoft.graph.application" Nullable="false"/>
<Parameter Name="passwordCredential" Type="microsoft.graph.passwordCredential"/>
<ReturnType Type="microsoft.graph.passwordCredential" Nullable="false"/>
</Action>
...
应返回生成的凭据,如:

{
    "@odata.context": "https://graph.microsoft.com/beta/$metadata#microsoft.graph.passwordCredential",
    "customKeyIdentifier": null,
    "endDateTime": "2119-05-01T10:18:33.4995826Z",
    "keyId": "...",
    "startDateTime": "2019-05-01T10:18:33.4995826Z",
    "secretText": "...",
    "hint": "...",
    "displayName": "new test password"
}

谢谢。不过,我想知道,在Microsoft删除修补密码凭据的功能后,如何添加/修改keyID/SecretText和提示,这可能吗?从您提到的内容来看,似乎将添加removePassword。这将使您能够添加新密码,然后删除旧密码。
{
    "@odata.context": "https://graph.microsoft.com/beta/$metadata#microsoft.graph.passwordCredential",
    "customKeyIdentifier": null,
    "endDateTime": "2119-05-01T10:18:33.4995826Z",
    "keyId": "...",
    "startDateTime": "2019-05-01T10:18:33.4995826Z",
    "secretText": "...",
    "hint": "...",
    "displayName": "new test password"
}