Skip to content

Commit

Permalink
Merge pull request #723 from reshmee011/main
Browse files Browse the repository at this point in the history
New script to get spfx details
  • Loading branch information
pkbullock authored Aug 18, 2024
2 parents 533a182 + 1dfe958 commit b61a3bd
Show file tree
Hide file tree
Showing 3 changed files with 151 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
---
plugin: add-to-gallery
---

# Retrieve SPFx Details from Tenant and Site Collection App Catalogs

## Summary

This script will help to gather detailed information about SPFx solutions installed in SharePoint environment, such as API permissions, for auditing, inventory, or compliance purposes from both the tenant-level and site collection app catalogs.

![Example Screenshot](assets/preview.png)

### Prerequisites

- The user account that runs the script must have access to the SharePoint Online site.

# [PnP PowerShell](#tab/pnpps)

```powershell
$AdminCenterURL= Read-Host -Prompt "Enter admin tenant collection URL";
$tenantAppCatalogUrl = Get-PnPTenantAppCatalogUrl
$dateTime = (Get-Date).toString("dd-MM-yyyy")
$invocation = (Get-Variable MyInvocation).Value
$directorypath = Split-Path $invocation.MyCommand.Path
$fileName = "\InventorySPFx-" + $dateTime + ".csv"
$OutPutView = $directorypath + $fileName
cd $PSScriptRoot
Connect-PnPOnline $tenantAppCatalogUrl -Interactive
$appCatConnection = Get-PnPConnection
Connect-PnPOnline $AdminCenterURL -Interactive
$adminConnection = Get-PnPConnection
$appsDetails = @()
#Get associated sites with hub
$sites = Get-PnPTenantSite -Detailed -Connection $adminConnection | Where-Object -Property Template -NotIn ("PWA#0","SRCHCEN#0", "REDIRECTSITE#0", "SPSMSITEHOST#0", "APPCATALOG#0", "POINTPUBLISHINGHUB#0", "POINTPUBLISHINGTOPIC#0","EDISC#0", "STS#-1")
$RestMethodUrl = '/_api/web/lists/getbytitle(''Apps%20for%20SharePoint'')/items?$select=Title,LinkFilename,SkipFeatureDeployment,ContainsTeamsManifest,ContainsVivaManifest,SupportsTeamsTabs,WebApiPermissionScopesNote,ContainsTenantWideExtension,IsolatedDomain,PackageDefaultSkipFeatureDeployment,IsClientSideSolutionCurrentVersionDeployed,ExternalContentDomains,IsClientSideSolutionDeployed,IsClientSideSolution,AppPackageErrorMessage,IsValidAppPackage,SharePointAppCategory,AppDescription,AppShortDescription'
$apps = (Invoke-PnPSPRestMethod -Url $RestMethodUrl -Method Get -Connection $appCatConnection).Value
#export details of apps
$apps| foreach-object{
$app = $_
$app | Add-Member -MemberType NoteProperty -name "Site Url" -value $tenantAppCatalogUrl
$appsDetails += $app
}
$sites | select url | ForEach-Object {
write-host "Processing Site:" $_.url -f Yellow
$Site = Get-PnPTenantSite $_.url -Connection $adminConnection
Connect-PnPOnline -Url $Site.url -Interactive
$siteConnection = Get-PnPConnection
try{
if((Get-PnPSiteCollectionAppCatalog -CurrentSite)){
$apps = (Invoke-PnPSPRestMethod -Url $RestMethodUrl -Method Get -Connection $siteConnection).Value
$apps| foreach-object{
$app = $_
$app | Add-Member -MemberType NoteProperty -name "Site Url" -value $Site.url
$appsDetails += $app
}
}
}
catch{
write-host -f Red $_.Exception.Message
}
}
#Export the result Array to CSV file
$appsDetails | Export-CSV $OutPutView -Force -NoTypeInformation
```

[!INCLUDE [More about PnP PowerShell](../../docfx/includes/MORE-PNPPS.md)]

***

## Source Credit

Sample first appeared on [Retrieve SPFx Details from Tenant and Site Collection App Catalogs Using PowerShell](https://reshmeeauckloo.com/posts/powershell-get-spfx-details-tenant-sitecollection-appcatalog/)

## Contributors

| Author(s) |
|-----------|
| [Reshmee Auckloo](https://github.com/reshmee011) |


[!INCLUDE [DISCLAIMER](../../docfx/includes/DISCLAIMER.md)]
<img src="https://m365-visitor-stats.azurewebsites.net/script-samples/scripts/spo-get-details-spfx-packages-tenant-sitecollection-appcatalog" aria-hidden="true" />
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
[
{
"name": "spo-get-details-spfx-packages-tenant-sitecollection-appcatalog",
"source": "pnp",
"title": "Retrieve SPFx Details from Tenant and Site Collection App Catalogs",
"shortDescription": "Retrieve detailed information about SPFx solutions installed in SharePoint environment, such as API permissions from both the tenant-level and site collection app catalogs.",
"url": "https://pnp.github.io/script-samples/spo-get-details-spfx-packages-tenant-sitecollection-appcatalog/README.html",
"longDescription": [
"Retrieve detailed information about SPFx solutions installed in SharePoint environment, such as API permissions, for auditing, inventory, or compliance purposes from both the tenant-level and site collection app catalogs."
],
"creationDateTime": "2024-08-09",
"updateDateTime": "2024-08-09",
"products": [
"SharePoint",
"SPFx"
],
"metadata": [
{
"key": "PNP-POWERSHELL",
"value": "2.5.0"
}
],
"categories": [
"Report"
],
"tags": [
"modern",
"Connect-PnPOnline",
"Get-PnPTenantSite",
"Get-PnPTenantAppCatalogUrl",
"Get-PnPSiteCollectionAppCatalog",
"Invoke-PnPSPRestMethod",
"Get-PnPWeb",
"Get-PnPApp"
],
"thumbnails": [
{
"type": "image",
"order": 100,
"url": "https://raw.githubusercontent.com/pnp/script-samples/main/scripts/spo-get-details-spfx-packages-tenant-sitecollection-appcatalog/assets/preview.png",
"alt": ""
}
],
"authors": [
{
"gitHubAccount": "reshmee011",
"company": "",
"pictureUrl": "https://avatars.githubusercontent.com/u/7693852?v=4",
"name": "Reshmee Auckloo"
}
],
"references": [
{
"name": "Want to learn more about PnP PowerShell and the cmdlets",
"description": "Check out the PnP PowerShell site to get started and for the reference to the cmdlets.",
"url": "https://aka.ms/pnp/powershell"
}
]
}
]

0 comments on commit b61a3bd

Please sign in to comment.