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() |
Using CSOM with MFA (you can use my DLL set from: https://www.pbnet.ro/tools_dl/CSOM-27JAN2020.zip
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
#Loading Assemblies [System.Reflection.Assembly]::LoadFile("C:\CSOM\Microsoft.SharePoint.Client.dll") [System.Reflection.Assembly]::LoadFile("C:\CSOM\Microsoft.SharePoint.Client.Runtime.dll") [System.Reflection.Assembly]::LoadFile("C:\CSOM\\Microsoft.SharePoint.Client.Publishing.dll") #download https://www.nuget.org/packages/Microsoft.IdentityModel.Clients.ActiveDirectory/3.19.8 [System.Reflection.Assembly]::LoadFile("C:\CSOM\Microsoft.IdentityModel.Clients.ActiveDirectory.dll") #download https://www.nuget.org/packages/SharePointPnPCoreOnline/3.26.2010 [System.Reflection.Assembly]::LoadFile("C:\CSOM\OfficeDevPnP.Core.dll") $siteURL="https://pbnet.sharepoint.com/teams/ASSETS1" $authManager = new-object OfficeDevPnP.Core.AuthenticationManager; $context = $authManager.GetWebLoginClientContext($siteUrl); # Get the list and root folder $t = $context.Web.Lists.EnsureSiteAssetsLibrary() $context.Load($t) $context.ExecuteQuery() |
Or, another way to re-provision the Assets library would be by Enabling the WikiPageHomePage feature on the site collection
Using PnP:
|
1 2 3 4 |
#Disable WikiPageHomePage Disable-PnPFeature -Identity 00bfea71-d8fe-4fec-8dad-01c19a6e4053 #Enable WikiPageHomePage Enable-PnPFeature -Identity 00bfea71-d8fe-4fec-8dad-01c19a6e4053 |
Enjoy!
