Remove an Organization Assets Library from SharePoint Online using PowerShell

Remove an Organization Assets Library from SharePoint Online using PowerShell

In my previous blog post – Create an Organization Assets Library in SharePoint Online, I explained what is an Organization Assets Library in SharePoint, different types of organization assets libraries and provided a step-by-step guide on how to create organization assets libraries in SharePoint Online using SharePoint Online PowerShell, PnP PowerShell and CLI for Microsoft 365.

In this blog post, we will explore how to remove or unregister a SharePoint online document library from organization assets libraries using PnP PowerShell and CLI for Microsoft 365.

Using PnP PowerShell

You can use below PnP PowerShell script to remove a SharePoint document library that was designated as a central location for organization assets across the tenant:

# URL of SharePoint online document library
$libraryUrl = "https://contoso.sharepoint.com/sites/OrgAssets/CompanyLogos"

# SharePoint online admin center URL
$adminCenterUrl = Read-Host -Prompt "Enter your SharePoint admin center site URL (e.g https://contoso-admin.sharepoint.com/)"

# Connect to SharePoint online admin center
Connect-PnPOnline -Url $adminCenterUrl -Interactive

# Remove organization assets library from SharePoint Online
Remove-PnPOrgAssetsLibrary -LibraryUrl $libraryUrl

# Disconnect SharePoint online connection
Disconnect-PnPOnline

Using CLI for Microsoft 365

Use below CLI for Microsoft 365 script to unregister the given SharePoint Online document library as an organizational asset source in the tenant:

# URL of SharePoint online document library
$libraryUrl = "https://contoso.sharepoint.com/sites/OrgAssets/CompanyLogos"

# Get Credentials to connect
$m365Status = m365 status
if ($m365Status -match "Logged Out") {
m365 login
}

# Unregister a SharePoint document library from organization assets libraries
m365 spo orgassetslibrary remove --libraryUrl $libraryUrl --force

# Disconnect SharePoint online connection
m365 logout

Note: It might take up to 24 hours to remove an organization assets library from “Your organization” tab in the file/image picker after you unregister it from the SharePoint tenant organization asset libraries.

Learn more

2 thoughts on “Remove an Organization Assets Library from SharePoint Online using PowerShell

Leave a comment