none
Where or how to see all registered apps with their expiry dates, on SharePoint Online? RRS feed

  • Question

  • Hi there

    Where or how to see all registered apps with their expiry dates, on SharePoint Online?

    (Users may have registered apps using /_layouts/15/AppRegNew.aspx and /_layouts/15/AppInv.aspx) I need to see a list of all of them.

    Thanks.


    • Edited by ran009 Monday, July 8, 2019 8:25 PM
    Monday, July 8, 2019 8:16 PM

Answers

  • Hi, ran,

    For the list with all registered apps with expiry dates. You will need to read these two official docs:

    https://docs.microsoft.com/en-us/office365/enterprise/powershell/connect-to-office-365-powershell

    This article provides introduction about how to connect to your Office 365 PowerShell. https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/replace-an-expiring-client-secret-in-a-sharepoint-add-in

    After having connected to O365 PowerShell, you will be able to Find out the expiration dates of the SharePoint Add-ins installed to the Office 365 tenancy with this doc. You need to connect MSolService and run the following code with the tutorial

    $applist = Get-MsolServicePrincipal -all  |Where-Object -FilterScript { ($_.DisplayName -notlike "*Microsoft*") -and ($_.DisplayName -notlike "autohost*") -and  ($_.ServicePrincipalNames -notlike "*localhost*") }
    
    foreach ($appentry in $applist) {
        $principalId = $appentry.AppPrincipalId
        $principalName = $appentry.DisplayName
    
        Get-MsolServicePrincipalCredential -AppPrincipalId $principalId -ReturnKeyValues $false | ? { $_.Type -eq "Password" } | % { "$principalName;$principalId;" + $_.KeyId.ToString() +";" + $_.StartDate.ToString() + ";" + $_.EndDate.ToString() } | out-file -FilePath c:\temp\appsec.txt -append
    }

    You can change the output path with your requirements.

    The txt file will be like this:

    Best Regards

    Jerry


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    • Marked as answer by ran009 Tuesday, July 9, 2019 11:33 PM
    Tuesday, July 9, 2019 6:39 AM

All replies

  • Hi

    you can try the below code

    sing (ClientContext context = new ClientContext("http://weburl/"))
                {
                    Web web = context.Web;
                    web.Context.Load(web);
                    web.Context.ExecuteQuery();
    
                    // Get all Add-ins installed on the web
                    var addInInstance = AppCatalog.GetAppInstances(context, web);
                    addInInstance.Context.Load(addInInstance);
                    addInInstance.Context.ExecuteQuery();
    
                    foreach (var appInstance in addInInstance)
                    {
    
                        //Check whether it is Remote hosted Add-in
                        if (string.IsNullOrEmpty(appInstance.AppWebFullUrl))
                        {
                            Console.WriteLine("This is a remote hosted add-in");
                            // You can now get all the information about your appInstance object
                            Console.WriteLine("Add-in Title: " + appInstance.Title);
                            Console.WriteLine("Status: " + appInstance.Status);
                            Console.WriteLine("Start Page: " + appInstance.StartPage);
                            Console.WriteLine("Add-in Id: " + appInstance.Id);
                        }
                    }
                }


    Please remember to click Mark as Answer on the answer if it helps you

    Monday, July 8, 2019 9:18 PM
  • Hi Lakshmanan
    Is this PowerShell code? I ran it using SP Online Management Shell and got these errors:

    PS C:\scripts\PowerShell> .\GetRegisteredApps.ps1
    At C:\scripts\PowerShell\GetRegisteredApps.ps1:5 char:42
    +                 web.Context.ExecuteQuery();
    +                                          ~
    An expression was expected after '('.
    At C:\scripts\PowerShell\GetRegisteredApps.ps1:8 char:17
    +                 var addInInstance = AppCatalog.GetAppInstances(contex ...
    +                 ~~~
    The 'var' keyword is not supported in this version of the language.
    At C:\scripts\PowerShell\GetRegisteredApps.ps1:8 char:71
    + ...         var addInInstance = AppCatalog.GetAppInstances(context, web);
    +                                                                   ~
    Missing argument in parameter list.
    At C:\scripts\PowerShell\GetRegisteredApps.ps1:10 char:52
    +                 addInInstance.Context.ExecuteQuery();
    +                                                    ~
    An expression was expected after '('.
    At C:\scripts\PowerShell\GetRegisteredApps.ps1:12 char:26
    +                 foreach (var appInstance in addInInstance)
    +                          ~
    Missing variable name after foreach.
    At C:\scripts\PowerShell\GetRegisteredApps.ps1:12 char:26
    +                 foreach (var appInstance in addInInstance)
    +                          ~~~
    The 'var' keyword is not supported in this version of the language.
    At C:\scripts\PowerShell\GetRegisteredApps.ps1:2 char:13
    +             {
    +             ~
    Missing closing '}' in statement block or type definition.
    At C:\scripts\PowerShell\GetRegisteredApps.ps1:12 char:58
    +                 foreach (var appInstance in addInInstance)
    +                                                          ~
    Unexpected token ')' in expression or statement.
    At C:\scripts\PowerShell\GetRegisteredApps.ps1:20 char:61
    +                         Console.WriteLine("Add-in Title: " + appInsta ...
    +                                                             ~
    You must provide a value expression following the '+' operator.
    At C:\scripts\PowerShell\GetRegisteredApps.ps1:20 char:62
    + ...              Console.WriteLine("Add-in Title: " + appInstance.Title);
    +                                                       ~~~~~~~~~~~~~~~~~
    Unexpected token 'appInstance.Title' in expression or statement.
    Not all parse errors were reported.  Correct the reported errors and try again.
        + CategoryInfo          : ParserError: (:) [], ParseException
        + FullyQualifiedErrorId : ExpectedExpression
    
    

    Any thoughts please?

    Thanks.



    • Edited by ran009 Monday, July 8, 2019 10:03 PM
    Monday, July 8, 2019 10:01 PM
  • Hi, ran,

    For the list with all registered apps with expiry dates. You will need to read these two official docs:

    https://docs.microsoft.com/en-us/office365/enterprise/powershell/connect-to-office-365-powershell

    This article provides introduction about how to connect to your Office 365 PowerShell. https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/replace-an-expiring-client-secret-in-a-sharepoint-add-in

    After having connected to O365 PowerShell, you will be able to Find out the expiration dates of the SharePoint Add-ins installed to the Office 365 tenancy with this doc. You need to connect MSolService and run the following code with the tutorial

    $applist = Get-MsolServicePrincipal -all  |Where-Object -FilterScript { ($_.DisplayName -notlike "*Microsoft*") -and ($_.DisplayName -notlike "autohost*") -and  ($_.ServicePrincipalNames -notlike "*localhost*") }
    
    foreach ($appentry in $applist) {
        $principalId = $appentry.AppPrincipalId
        $principalName = $appentry.DisplayName
    
        Get-MsolServicePrincipalCredential -AppPrincipalId $principalId -ReturnKeyValues $false | ? { $_.Type -eq "Password" } | % { "$principalName;$principalId;" + $_.KeyId.ToString() +";" + $_.StartDate.ToString() + ";" + $_.EndDate.ToString() } | out-file -FilePath c:\temp\appsec.txt -append
    }

    You can change the output path with your requirements.

    The txt file will be like this:

    Best Regards

    Jerry


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    • Marked as answer by ran009 Tuesday, July 9, 2019 11:33 PM
    Tuesday, July 9, 2019 6:39 AM