Skip to content

Commit

Permalink
Merge pull request #472 from kris6673/List-Oauth-appid-fix-API
Browse files Browse the repository at this point in the history
Fix oauth colum giving object id and not application id
  • Loading branch information
KelvinTegelaar authored Nov 13, 2023
2 parents 6a8e2bd + 8e809e8 commit de70881
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions ListOAuthApps/run.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ if ($TenantFilter -eq "AllTenants") { $Tenants = (Get-Tenants).defaultDomainName
try {
$GraphRequest = foreach ($Tenant in $Tenants) {
try {
$ServicePrincipals = New-GraphGetRequest -uri "https://graph.microsoft.com/beta/servicePrincipals?`$select=id,displayName" -tenantid $Tenant
$ServicePrincipals = New-GraphGetRequest -uri "https://graph.microsoft.com/beta/servicePrincipals?`$select=id,displayName,appid" -tenantid $Tenant
New-GraphGetRequest -uri "https://graph.microsoft.com/beta/oauth2PermissionGrants" -tenantid $Tenant | ForEach-Object {
$CurrentServicePrincipal = ($ServicePrincipals | Where-Object -Property id -EQ $_.clientId)
[PSCustomObject]@{
Tenant = $Tenant
Name = ($ServicePrincipals | Where-Object -Property id -EQ $_.clientId).displayName
ID = $_.clientId
Scope = ($_.scope -join ',')
StartTime = $_.startTime
Tenant = $Tenant
Name = $CurrentServicePrincipal.displayName
ApplicationID = $CurrentServicePrincipal.appid
ObjectID = $_.clientId
Scope = ($_.scope -join ',')
StartTime = $_.startTime
}
}
$StatusCode = [HttpStatusCode]::OK
Expand Down

0 comments on commit de70881

Please sign in to comment.