Skip to content

Commit

Permalink
Merge pull request #734 from kasperbolarsen/main
Browse files Browse the repository at this point in the history
New script that will locate each page where the Script Editor web part is used
  • Loading branch information
pkbullock authored Aug 29, 2024
2 parents 1412ec4 + d0bc3fc commit 7439697
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 5 deletions.
4 changes: 2 additions & 2 deletions scripts/spo-ensure-cts-before-template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
plugin: add-to-gallery
---

# Ensure all required Content Types are available before Get-PnPContentType
# Ensure all required Content Types are available before Get-PnPSiteTemplate

## Summary

If one of the Content Types you are using on your master site is part of a Content Type Hierachy, you need to ensure that all the Content Types are available on the site before you use the `Get-PnPContentType` cmdlet. This will ensure that you can deploy the Template without any issues.
If one of the Content Types you are using on your master site is part of a Content Type Hierachy, you need to ensure that all the Content Types are available on the site before you use the `Get-PnPSiteTemplate` cmdlet. This will ensure that you can deploy the Template without any issues.

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

Expand Down
6 changes: 3 additions & 3 deletions scripts/spo-ensure-cts-before-template/assets/sample.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
{
"name": "spo-ensure-cts-before-template",
"source": "pnp",
"title": "Ensure all required Content Types are available before Get-PnPContentType ",
"title": "Ensure all required Content Types are available before Get-PnPSiteTemplate ",
"shortDescription": "This is a Content type pre-burner before extracting a PnP Template",
"url": "https://pnp.github.io/script-samples/spo-ensure-cts-before-template/README.html",
"longDescription": [
"If one of the Content Types you are using on your master site is part of a Content Type Hierachy, you need to ensure that all the Content Types are available on the site before you use the `Get-PnPContentType` cmdlet. This will ensure that you can deploy the Template without any issues."
"If one of the Content Types you are using on your master site is part of a Content Type Hierachy, you need to ensure that all the Content Types are available on the site before you use the `Get-PnPSiteTemplate` cmdlet. This will ensure that you can deploy the Template without any issues."
],
"creationDateTime": "2024-08-22",
"updateDateTime": "2024-08-22",
Expand All @@ -25,7 +25,7 @@
"Configure"
],
"tags": [
"Get-PnPContentType","Add-PnPContentTypesFromContentTypeHub"
"Get-PnPContentType","Add-PnPContentTypesFromContentTypeHub","Get-PnPSiteTemplate"
],
"thumbnails": [
{
Expand Down
55 changes: 55 additions & 0 deletions scripts/spo-find-script-editor-webpart-using-search/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
plugin: add-to-gallery
---

# Find every page that contains a Modern Script Editor web part

> [!Note]
> This is a submission helper template please find the [contributor guidance](/docfx/contribute.md) to help you write this scenario.
## Summary

Since the Modern Script Editor web part is impacted by the automatic disabling af Custom Scripting every 24 hours, it is a good idea to find all pages that contain this web part. This script will search through all pages in a site collection and return the pages that contain the Modern Script Editor web part.

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


# [PnP PowerShell](#tab/pnpps)

```powershell
#locate all page containing a Script Editor Web part
$url = "https://contoso.sharepoint.com/sites/somesite"
#login in a way that allows you to search all sites. I usually use -ManagedIdentity in Azure Automation/Function
$conn = Connect-PnPOnline -Url $url -Interactive -ReturnConnection -WarningAction Ignore
$IdForScriptEditorWebPart = "3a328f0a-99c4-4b28-95ab-fe0847f657a3"
$query = 'SPFxExtensionJson:"'+$IdForScriptEditorWebPart+'"'
$result = Invoke-PnPSearchQuery -Query $query -Connection $conn -All -SelectProperties "Path", "FileName"
$result.ResultRows.Count
#export to csv
$data = @()
foreach($row in $result.ResultRows)
{
$item = New-Object PSObject
$item | Add-Member -MemberType NoteProperty -Name "Path" -Value $row.Path
$item | Add-Member -MemberType NoteProperty -Name "FileName" -Value $row.FileName
$data += $item
}
$data | Export-Csv -Path "C:\temp\searchresult.csv" -NoTypeInformation
```
[!INCLUDE [More about PnP PowerShell](../../docfx/includes/MORE-PNPPS.md)]
***


## Contributors

| Author(s) |
|-----------|
| Kasper Larsen |

[!INCLUDE [DISCLAIMER](../../docfx/includes/DISCLAIMER.md)]
<img src="https://m365-visitor-stats.azurewebsites.net/script-samples/scripts/spo-find-script-editor-webpart-using-search" 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.
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,55 @@
[
{
"name": "spo-find-script-editor-webpart-using-search",
"source": "pnp",
"title": "Find every page that contains a Modern Script Editor web part",
"shortDescription": "Locate use of Modern Script Editor",
"url": "https://pnp.github.io/script-samples/spo-find-script-editor-webpart-using-search/README.html",
"longDescription": [
""
],
"creationDateTime": "2024-08-25",
"updateDateTime": "2024-08-25",
"products": [
"SharePoint",
"Azure"
],
"metadata": [
{
"key": "PNP-POWERSHELL",
"value": "2.9.0"
}
],
"categories": [
"Modernize",
"Report",
"Security"
],
"tags": [
"Invoke-PnPSearchQuery"
],
"thumbnails": [
{
"type": "image",
"order": 100,
"url": "https://raw.githubusercontent.com/pnp/script-samples/main/scripts/spo-find-script-editor-webpart-using-search/assets/preview.png",
"alt": "Preview of the sample Find every page that contains a Modern Script Editor web part"
}
],
"authors": [
{
"gitHubAccount": "kasperbolarsen",
"company": "",
"pictureUrl": "https://github.com/kasperbolarsen.png",
"name": "Kasper Larsen"
}
],
"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 7439697

Please sign in to comment.