Skip to content

Instantly share code, notes, and snippets.

View ypcode's full-sized avatar

Yannick Plenevaux ypcode

View GitHub Profile
<AppPermissionRequests AllowAppOnlyPolicy="true">
<AppPermissionRequest Scope="http://sharepoint/content/sitecollection/web" Right="FullControl"/>
</AppPermissionRequests>
Connect-PnPOnline https://yourtenant.sharepoint.com/sites/yoursite
$path = ".\The\Path\to\your\template.xml"
Apply-PnPProvisioningTemplate -Path $path
<pnp:Provisioning
xmlns:pnp="http://schemas.dev.office.com/PnP/2017/05/ProvisioningSchema">
<pnp:Preferences Generator="OfficeDevPnP.Core, Version=2.18.1709.0, Culture=neutral, PublicKeyToken=3751622786b357c2" />
<pnp:Templates ID="CONTAINER-TEMPLATE-WEBHOOK">
<pnp:ProvisioningTemplate ID="TEMPLATE-WEBHOOK" Version="1" BaseSiteTemplate="STS#0" Scope="RootSite">
<pnp:Lists>
<pnp:ListInstance Title="testwebhook" TemplateType="100" Url="Lists/testwebhook">
<pnp:Webhooks>
<pnp:Webhook ServerNotificationUrl="https://your-functions.azurewebsites.net/api/sample-webhook" ExpiresInDays="179" />
</pnp:Webhooks>
import pnp from "pnp";
pnp.sp.web.lists.getByTitle("testwebhook")
.subscriptions
.add("https://your-functions.azurewebsites.net/api/sample-webhook", "2017-12-01T00:00:00+00:00")
.then(r => console.log("Webhook added"))
.catch(r => console.log(r));
Connect-PnPOnline https://yourtenant.sharepoint.com/sites/yoursite
# "testwebhook" is the name of our target list
Add-PnPWebhookSubscription -List testwebhook -NotificationUrl https://your-functions.azurewebsites.net/api/sample-webhook
# The command above outputs the following
# Id : 080e41c2-3c30-4c4d-8d1c-fa22249aedc0
# ClientState :
# ExpirationDateTime : 12-Mar-18 22:00:00
# NotificationUrl : https://your-functions.azurewebsites.net/api/sample-webhook
# Resource : 6efa3b51-f514-4b88-9117-3d158e3f8fe2
############################################################
# Set here the URL of your site
$targetWebUrl = "https://yourtenant.sharepoint.com/sites/yoursite"
# Set the name of the custom action here (do not really matter in this case but allows to identify it)
$customAction = "ImportantMarker"
# Set here the Id of your extension. You can find it in the manifest in your SPFx solution
$componentId = [GUID]"42887c3b-0b7c-4fc4-8510-1107c73495c9"
# Set here the Id or name of the list
$listNameOrId = "MOTD"
# Set here the internal name of the field to bind the extension to
############################################################
# Set here the URL of your site
$targetWebUrl = "https://yourtenant.sharepoint.com/sites/yoursite"
# Set the name of the custom action here (do not really matter in this case but allows to identify it)
$customAction = "MotdBanner"
# Set here the Id of your extension. You can find it in the manifest in your SPFx solution
$componentId = "42887c3b-0b7c-4fc4-8510-1107c73495c9"
############################################################
Connect-PnPOnline $targetWebUrl
Add-PnPCustomAction -Name $customAction -Title "MOTD" -Location "ClientSideExtension.ApplicationCustomizer" -ClientSideComponentId $componentId -ClientSideComponentProperties "{}"
# This script allows to associate a SPFx ListViewCommandSet extension to a list type (100)
######################################################################
# Due to some inconsistency in accepted Cmdlet arguments
# We need to work around it by updating manually the RegistrationId and RegistrationType values
# The ClientSideComponentProperties is required even if the extension don't need any property
######################################################################
# Target web URL
$targetWebUrl = "https://yourtenant.sharepoint.com/sites/yoursite"
# Set the name of your custom action here
$customActionName = "MARK_AS_IMPORTANT"
param (
[Parameter(Mandatory=$true)]
[string] $TargetWeb,
[Parameter(Mandatory=$true)]
[string] $TasksLibraryName,
[Parameter(Mandatory=$false)]
[string] $PageName = "Kanban Board",
[Parameter(Mandatory=$false)]
[string] $StatusFieldName="Status"
)
Connect-PnPOnline https://contoso.sharepoint.com/sites/dev -Credentials contoso
$page = Add-PnPClientSidePage -Name "Hello World"
Add-PnPClientSidePageSection -Page $page -SectionTemplate TwoColumn
Add-PnPClientSideText -Page $page -Section 1 -Column 1 -Text "Hello"
Add-PnPClientSideText -Page $page -Section 1 -Column 2 -Text "World!"
Add-PnPClientSidePageSection -Page $page -SectionTemplate OneColumn
Add-PnPClientSideWebPart -Page $page -Section 2 -Column 1 -DefaultWebPartType BingMap