Share via

Need power she'll or Ms graph script

j prasad 31 Reputation points
2024-11-26T16:15:17.97+00:00

Need script to check the below. 1.All enabled app registration with empty notes details. 2.All enabled enterprise apps with empty notes and email notification

Microsoft Security | Microsoft Entra | Microsoft Entra ID

1 answer

Sort by: Most helpful
  1. VenkateshDodda-MSFT 25,251 Reputation points Microsoft Employee Moderator
    2024-11-27T07:11:48.8633333+00:00

    @j prasad Thanks for posting your question in Microsoft Q&A.

    Based on your requirement we have written the below Power Shell and tested in our environment from local machine which is working fines as well.

    Connect-MgGraph -Scopes 'Application.Read.All'
    $listAppRegistrations = Get-MgApplication
    $listEnterpriseApps = Get-MgServicePrincipal 
    
    $AppRegistrations = @()
    $EnterpriseApps = @()
    
    #To check the App registrations with notes as empty
    foreach( $item in $listAppRegistrations){
        if($item.Notes.Length -eq 0 ){
          $AppRegistrations += $item.DisplayName
        }
    }
    
    Write-output "Below are list of AppRegistration with Notes as Empty"
    Write-Output $AppRegistrations
    
    #To check the Enterprise registration with notes as empty
    foreach($servicePrincipal in $listEnterpriseApps)
    {
        if($servicePrincipal.Notes.Length -eq 0 -and $servicePrincipal.AccountEnabled -eq $true -and $servicePrincipal.NotificationEmailAddresses.Length -eq 0){
            
            $EnterpriseApps += $servicePrincipal.DisplayName
        }
    }
    
    Write-Output "Below are list of EnterpriseApps which are enable but Notes and NotificationEmailAddress are Empty" 
    Write-Output $EnterpriseApps
    

    Note : Please modify the output formats based on your requirements.

    Please accept as "Yes" if the answer is helpful so that it can help others in the community.

    Hope this helps, let me know if you have any further questions on this.

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.