User Tools

Site Tools


technet:graph:serviceprincipalsignin

Service Principal Sign-In Activity

  1. Connect-MgGraph -Scopes AuditLog.Read.All
  2. Select-MgProfile Beta
  3. [array]$AuditData = Invoke-MgGraphRequest -Method GET -Uri "https://graph.microsoft.com/beta/reports/servicePrincipalSignInActivities"
  4. If (!($AuditData)) { Write-Host "Error fetching service principal sign in activity data..." ; break }
  5. $AuditData = $AuditData.Value
  6. $Report = [System.Collections.Generic.List[Object]]::new()
  7. ForEach ($SP in $AuditData) {
  8. $SpAppId = $SP['appId']
  9. $ServicePrincipal = Get-MgServicePrincipal -Filter "Appid eq '$SpAppId'"
  10. $SPName = $ServicePrincipal.DisplayName
  11. If ($SPName) {
  12. $SPCreatedDate = Get-Date($ServicePrincipal.additionalProperties.createdDateTime) -format g
  13. } Else {
  14. $SPCreatedDate = $Null }
  15. $ReportLine = [PSCustomObject]@{
  16. AppId = $SP['appId']
  17. 'Display name' = $ServicePrincipal.DisplayName
  18. Publisher = $ServicePrincipal.PublisherName
  19. 'Sign in audience' = $ServicePrincipal.SignInAudience
  20. 'Last sign in' = $SP['lastSignInActivity'].lastSignInDateTime
  21. 'Last app sign in' = $SP['applicationAuthenticationClientSignInActivity'].lastSignInDateTime
  22. 'Last delegate sign in' = $SP['delegatedClientSignInActivity'].lastSignInDateTime
  23. }
  24. $Report.Add($ReportLine)
  25. }
  26. # Filter out the records that can't be resolved against service principals in the tenant
  27. $ReportSPs = $Report | Where-Object {$Null -ne $_.'Display name'}
  28. $ReportSPs | Out-GridView

Zdroj: https://office365itpros.com/2023/06/14/app-governance-license/

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
technet/graph/serviceprincipalsignin.txt · Last modified: by fk