-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #734 from kasperbolarsen/main
New script that will locate each page where the Script Editor web part is used
- Loading branch information
Showing
6 changed files
with
115 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
scripts/spo-find-script-editor-webpart-using-search/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" /> |
Binary file added
BIN
+102 KB
scripts/spo-find-script-editor-webpart-using-search/assets/example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+17.8 KB
scripts/spo-find-script-editor-webpart-using-search/assets/preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 55 additions & 0 deletions
55
scripts/spo-find-script-editor-webpart-using-search/assets/sample.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
] | ||
} | ||
] |