Using MS-Graph Module
Connect to graph API
# log in initially
$passwd = ConvertTo-SecureString 'm7flq6%gsZ@cW9yA1!' -AsPlainText -Force
$creds = New-Object System.Management.Automation.PSCredential('[email protected]',$passwd)
Connect-AzAccount -Credential $creds
# get ms graph token
$Token = (Get-AzAccessToken -ResourceTypeName MSGraph).Token | ConvertTo-SecureString -AsPlainText -Force
Connect-MgGraph -AccessToken $Token
Use MS-Graph to set a new application password
# get the application id
Get-MgApplication -All | Where-Object {$_.Displayname -eq 'ASinesahkzcu3220396' }
# add the new application secret (not it from the list)
$params = @{ passwordCredential = @{
displayName = "Password friendly name"
}
}
Add-MgApplicationPassword -ApplicationId $appId -BodyParameter $params