当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] SharePoint Online:使用 PowerShell 从回收站删除网站集

作者:精品下载站 日期:2024-12-14 14:48:57 浏览:16 分类:玩电脑

SharePoint Online:使用 PowerShell 从回收站删除网站集


要求:从 SharePoint Online 的回收站中删除网站集。

如何从回收站删除 SharePoint Online 网站?

在本文中,我们将向您展示如何从 SharePoint Online 的回收站中删除网站集。从回收站删除网站集会永久删除网站集,并且如果没有 Microsoft 支持的帮助,则无法恢复网站。因此,在从回收站删除网站集之前,请确保您完全确定要删除它。

当我们删除 SharePoint Online 网站集时,它会转到回收站并在那里保留 93 天。但是,有时我们可能也想从回收站中完全删除该网站,原因如下:

  • 我们的存储配额不足,想要删除网站集以获得空间。
  • 我们需要创建一个与已删除网站具有相同 URL 的新网站集(否则,会出现错误:New-SPOSite:URL https://yourtenant.sharepoint.com 上已存在网站)

从回收站永久删除网站集

要从 SharePoint Online 的回收站中永久删除网站,请执行以下步骤:

  1. 登录 Office 365 管理 >> SharePoint Online 管理中心。
  2. 单击左侧导航栏中的“站点”>>“已删除站点”链接。
  3. 从列表中选择站点,然后单击工具栏中的“删除”按钮。
  4. 在提示中确认删除操作!

    [玩转系统] SharePoint Online:使用 PowerShell 从回收站删除网站集

让我们看看如何使用 SharePoint Online PowerShell 从回收站删除网站集。

SharePoint Online:使用 PowerShell 从回收站删除网站集

以下是使用Remove-SPODeletedSite cmdlet 从回收站删除网站的 SharePoint Online PowerShell:


#Define Parameter values
$AdminSiteURL = "https://crescent-admin.sharepoint.com/"
$DeletedSiteCollURL = "https://crescent.sharepoint.com/sites/DeletedSite"
 
#Connect to SharePoint Online
Connect-SPOService -url $AdminSiteURL -Credential (Get-Credential)

#Remove Deleted SharePoint Online Site Collection permanently
Remove-SPODeletedSite -identity $DeletedSiteCollURL -Confirm:$false

从 SharePoint Online 的回收站中永久删除所有网站集:

想要永久删除回收站中的所有网站吗?以下是用于删除所有已删除网站的 PowerShell:


#Define Parameter values
$AdminSiteURL = "https://crescent-admin.sharepoint.com/"
 
#Connect to SharePoint Online
Connect-SPOService -url $AdminSiteURL -Credential (Get-Credential)

#Permanently Remove all Deleted Sites
Get-SPODeletedSite | ForEach {
Write-host "Deleting Site " $_.Url
#sharepoint online powershell delete site from recycle bin
Remove-SPODeletedSite -Identity $_.Url -Confirm:$False
}

这将清空 SharePoint Online 中的租户回收站。这是关于删除 SharePoint Online 网站集的另一篇文章:如何使用 PowerShell 删除 SharePoint Online 中的网站集?

SharePoint Online:使用 PnP PowerShell 从回收站删除网站集

让我们使用 PnP PowerShell 从回收站 SharePoint Online 中删除网站集:


#Config Variables
$TenantURL = "https://Crescent.sharepoint.com"
$SiteURL = "https://Crescent.sharepoint.com/sites/Customers"

#Connect to PnP Online
Connect-PnPOnline -Url $TenantURL -Credentials (Get-Credential)

#Get the Deleted Site from Recycle Bin
$DeletedSite = Get-PnPTenantRecycleBinItem | Where {$_.URL -eq $SiteURL}

#Check if site exists in recycle bin
If($DeletedSite)
{
    #sharepoint online powershell delete site collection from recycle bin
    Clear-PnPTenantRecycleBinItem -Url $SiteURL -Force
    Write-host -f Green "Site '$SiteURL' Deleted from Recycle Bin Successfully!"
}
Else
{
    Write-host -f Yellow "Could not find Site '$SiteURL' in Recycle Bin!"
} 

结论:

在本文中,我们展示了如何使用 SharePoint Online 管理中心和 PowerShell 从 SharePoint Online 的回收站中删除网站集。按照这些步骤,您可以从回收站永久删除网站集以释放存储空间或出于其他原因。需要注意的是,永久删除网站集是不可逆的,因此应谨慎执行!

  • SharePoint Online:使用 PowerShell 搜索回收站
  • SharePoint Online:PowerShell 列出已删除的网站

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯