
Hi @Anonymous ,
Welcome to Q&A Forum!
Please follow the steps:
1.In my test, this is my .csv file named LibList.csv
2.Please run the below PowerShell script as an admin on the SharePoint Online Management Shell:
##Export the .csv data to SharePoint list
$Credentials = Get-Credential
$Site="https://xxxx.sharepoint.com/sites/yyyy"
$ListName = "zzzz"
Connect-PnPOnline -Url $Site -Credentials $Credentials
$CustomerData = Import-CSV "C:\temp\LibraryURL.csv"
foreach ($Record in $CustomerData){
Add-PnPListItem -List $ListName -Values @{
"Title"= $Record.'Title';
"SiteURL"= $Record.'SiteURL';
"LibraryURL"= $Record.'LibraryURL';
"FullURL"= $Record.'FullURL'
}
}
3.Then, run the below PowerShell script as an admin on the SharePoint Online Management Shell:
Note:
The user must have at least Edit permission for each of the SharePoint sites and Document libraries
##Delete Document library
#Enter user account and password
#The user must have at least Edit permission for each of the SharePoint sites and Document libraries
$Credentials = Get-Credential
#Parameter
$SiteURL = "https://xxxx.sharepoint.com/sites/yyyy"
$ListName = "zzzz"
#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Credentials $Credentials
$ListItems = Get-PnPListItem -List $ListName
ForEach($Item in $ListItems)
{
$LibName = $Item["Title"]
$Site = $Item["SiteURL"]
Connect-PnPOnline -Url $Site -Credentials $Credentials
$Library = Get-PnPList -Identity $LibName -ErrorAction SilentlyContinue
If($Library)
{
#sharepoint online powershell to delete library
Remove-PnPList -Identity $LibName -Recycle -Force
Write-host -f Green "Library '$LibName' Deleted Successfully!"
}
Else
{
Write-host -f Yellow "Could not find Library '$LibName'"
}
}
Thanks,
Echo Du
================================================
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.