PowerShell script – Enlist all apps in my site collection installed from marketplace or app catalog using PnP PowerShell

Hi All,
Greetings for the day!
Today, I am sharing one more very useful PowerShell script. How to enlist all installed apps in my site collection either from marketplace or app catalog.
Use case
- Microsoft recently stopped enabling of custom scripting. We have detailed article for the same. Microsoft 365 – Major Update – Removal of Custom Script setting in OneDrive and SharePoint web – https://knowledge-junction.in/2024/02/26/m365updatecustomscriptsetting/
- In our tenant, we have used third party webpart – “Modern Script Editor” webpart.
- These “Modern Script Editor” web part requires custom scripting enabled.
- Though Microsoft declared that existing “Modern Script Webpart” doesn’t get affected, we through to replace them either with OOB webpart or we can write our custom SPFX webpart.
- Before start implementation we thought to do impact analysis. So, one point is to enlist all the site collections and site pages within those, where the “Modern Script Editor” webpart is added.
- Hence this PowerShell script born.
PowerShell script – How to enlist all the installed apps either from marketplace or app catalog in my Site Collection.
Detailed PowerShell script steps
- Specifying the URL of Site Collection from which we need to get all installed apps.
$Url = "https://knowledgejunction1.sharepoint.com/"
- Get the credentials to connect to the Site Collection using – Get-Credential
$Credentials = Get-Credential
- Connect to the Site collection using – Connect-PnPOnline
Connect-PnPOnline –Url $Url –Credentials $Credentials
- Get the web object including AppTiles using – Get-PnPWeb
$web = Get-PnPWeb –Includes AppTiles
- Get all AppTiles
$appTiles = $web.AppTiles
Invoke-PnPQuery
- In SharePoint online, everything is app so we will get all the list/libraries as shown in figure below.

- Please notice, OOB SharePoint apps(list, libraries) has “AppPrincipalId” as null or empty as shown in above image.
- Apps which are installed from MarketPlace or app catalog, have “AppPrincipalId”.
- So, we could have condition if “AppPrincipalId” is not null, then the app is custom app as
if($appTile.AppPrincipalId -ne ''){
$appTile | Format-Table -AutoSize -Property Title, AppType, AppPrincipalId
}

App Types
- Doclib
- List
- Tenant
- Instance
- Feature
- CommonList
COMPLETE SCRIPT
<#
.SYNOPSIS
Get-InstalledApps generates a report of installed apps in my site collection either from appcatalog or marketplace.
.DESCRIPTION
This script get all apps from the given site collection. Script verifies if app have AppPrincipalId is available or not
If AppPrincipalId is available means, the app is installed from app catalogue or marketplace. Output is shown in console.
.EXAMPLE
Get-InstalledApps
.EXAMPLE
Get-InstalledApps
#>
#site collection URL from which we need to get installed app
$Url = "https://knowledgejunction1.sharepoint.com/"
#get the credentials
$Credentials = Get-Credential
#connect to the site
Connect-PnPOnline –Url $Url –Credentials $Credentials
#get instance of web object
$web = Get-PnPWeb –Includes AppTiles
#get all apss
$appTiles = $web.AppTiles
Invoke-PnPQuery
#traversing through all apps
foreach($appTile in $appTiles){
#condition to make sure App is not SharePoint OOB object
if($appTile.AppPrincipalId -ne ''){
$appTile | Format-Table -AutoSize -Property Title, AppType, AppPrincipalId
} #if
}#foreach
We have good amount of PowerShell articles, more than 200+ PowerShell script. Please have a look at PowerShell tutorial – https://knowledge-junction.in/category/technology-articles/powershell-tutorial/
REFERENCES
- Microsoft 365 – Major Update – Removal of Custom Script setting in OneDrive and SharePoint web – https://knowledge-junction.in/2024/02/26/m365updatecustomscriptsetting/
- Knowledge-Junction PowerShell tutorial – https://knowledge-junction.in/category/technology-articles/powershell-tutorial/
Thank you for reading 😊 Stay tuned for more such articles.
If you like this article or useful to you, kindly share and subscribe Knowledge-Junction.
Have a FANTASTIC time ahead! LIFE IS BEAUTIFUL 🙂

You must be logged in to post a comment.