There is a command az ad app permission admin-consent
in Azure CLI, it can grant Application & Delegated
permissions through admin-consent for the app.
So in your case, you could use a loop to run the command to grant permissions. Make sure you have installed the Azure CLI, and login with az login
as an admin in the AAD tenant, then run the commands below.
My sample grant the permissions for all the app in my tenant, it works in Windows, if you want to run it in Linux, use a loop syntax for bash, or you can modify it depend on your requirements.
$apps = az ad app list --all --query '[].appId' -o tsv
foreach($app in $apps){
az ad app permission admin-consent --id $app
}