I'm looking for a way to create a new Azure Active Directory application registration via a PowerShell script. I can create the application using the following script:
$appName = "CliApp"
az ad app create --display-name "$appName" --oauth2-allow-implicit-flow true
$appJson = az ad app list --query "[?displayName=='$appName']"
$app = $appJson | ConvertFrom-Json
az ad app update --id $app.appId --identifier-uris api://$($app.appId) api://$($appName.ToLower())
But as I understand it, in order to create a new scope, I need to call Graph API. Is that correct? Are there any examples on how to do that via Powershell? If so, how do I get an auth token using my credentials from Powershell?