[PnP/CSOM] – Reprovision SiteAssets library in SPO
OK, so here are several ways to re-provision the SiteAssets library on a SharePoint online site collection: Using PnP:
|
1 2 3 4 5 6 7 8 9 |
Connect-PnPOnline -Url https://pbnet.sharepoint.com/teams/ASSETS1 ` -ClientId "dfbd77ff-be64-XXX-XXX-17a62a02fd29" ` -Tenant "pbnet.onmicrosoft.com" ` -CertificatePath "C:\SPOPNP\pnpappcert.pfx" ` -CertificatePassword (ConvertTo-SecureString "XXXXXXXXXX" -AsPlainText -Force) $Web = Get-PnPWeb $Web.Lists.EnsureSiteAssetsLibrary() Invoke-PnPQuery |
Using CSOM (no MFA):
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
Add-Type -Path "C:\CSOM\Microsoft.SharePoint.Client.dll" Add-Type -Path "C:\CSOM\Microsoft.SharePoint.Client.Runtime.dll" # SharePoint site and credentials $siteUrl = "https://a830edad9050849testasset.sharepoint.com/sites/SITEASSETS1" $username = "admin@a830edad9050849testasset.onmicrosoft.com" # Get credentials $securePassword = Read-Host -Prompt "Enter your password" -AsSecureString $credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $securePassword) # Connect to SharePoint $context = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl) $context.Credentials = $credentials # Get the list and root folder $t = $context.Web.Lists.EnsureSiteAssetsLibrary() $context.Load($t) $context.ExecuteQuery() |
