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
Connect-PnPOnline -Url https://contoso.sharepoint.com/sites/project101 | |
$Web = Get-PnPWeb -Includes WebTemplatesGalleryFirstRunEnabled | |
$Web.WebTemplatesGalleryFirstRunEnabled = $false | |
$Web.Update() | |
Invoke-PnPQuery |
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
import { ServiceKey, ServiceScope } from '@microsoft/sp-core-library'; | |
import { SPHttpClient, MSGraphClientFactory, MSGraphClient } from '@microsoft/sp-http'; | |
import { PageContext } from '@microsoft/sp-page-context'; | |
export interface ICustomService { | |
getMyProfile(): Promise<IGraphUser>; | |
} | |
export interface IGraphUser { | |
businessPhones?: string[]; |
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
<View Scope='RecursiveAll'> | |
<ViewFields> | |
<FieldRef Name='FileLeafRef'/> | |
<FieldRef Name='Modified'/> | |
</ViewFields> | |
<Query> | |
<Where> | |
<Leq> | |
<FieldRef Name='Modified'/> | |
<Value Type='DateTime'>2022-03-25</Value> |
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
public async Task DisableTemplateGalleryDialog(SharePointClientContext context) | |
{ | |
Web web = context.Web; | |
context.Load(web); | |
await context.ExecuteQueryRetryAsync(); | |
web.NextStepsFirstRunEnabled = false; | |
web.Update(); | |
await context.ExecuteQueryRetryAsync(); | |
} |
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
public async Task DisableTemplateGalleryDialog(SharePointClientContext context) | |
{ | |
Web web = context.Web; | |
context.Load(web); | |
await context.ExecuteQueryRetryAsync(); | |
web.WebTemplatesGalleryFirstRunEnabled = false; | |
web.Update(); | |
await context.ExecuteQueryRetryAsync(); | |
} |
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
private async Task SetHideFromAddressLists(GraphServiceClient client, string groupId) | |
{ | |
var retry = true; | |
var retryCount = 0; | |
var body = new | |
{ | |
hideFromAddressLists = true | |
}; |
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
# Read CSV file with a column "URL" including the full URL to the sites to be deleted | |
$Sites = Import-Csv .\sites.csv | |
# Connect to admin site | |
Connect-PnPOnline -Url https://contoso-admin.sharepoint.com | |
# Delete all sites to recycle bin | |
$Sites | ForEach-Object { | |
Write-Host "Remove: $($_.URL)" | |
Remove-PnPTenantSite -Url $_.URL -Force |
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
# Read CSV file with a column "URL" including the full URL to the sites to be deleted | |
$Sites = Import-Csv .\sites.csv | |
# Connect to admin site | |
Connect-PnPOnline -Url https://contoso-admin.sharepoint.com | |
# Delete all sites to recycle bin | |
$Sites | ForEach-Object { | |
Write-Host "Remove: $($_.URL)" | |
$Site = Get-PnPTenantSite -Identity $_.URL |
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
function Get-CorpMicrosoftGraphAccessToken | |
{ | |
Param( | |
[Parameter(Mandatory=$true)] | |
[string]$TenantId, | |
[Parameter(Mandatory=$true)] | |
[string]$ClientId, | |
[Parameter(Mandatory=$true)] | |
[string]$ClientSecret | |
) |