【发布时间】:2019-09-07 09:12:06
【问题描述】:
我对 SharePoint Online Office 365 有一个要求。根据我的要求,我必须以编程方式使用 pnp csom 从 SharePoint Online Office 365 管理中心删除所有网站集。
任何人都可以建议我如何删除所有网站集?
【问题讨论】:
标签: sharepoint csom
我对 SharePoint Online Office 365 有一个要求。根据我的要求,我必须以编程方式使用 pnp csom 从 SharePoint Online Office 365 管理中心删除所有网站集。
任何人都可以建议我如何删除所有网站集?
【问题讨论】:
标签: sharepoint csom
您可以使用DeleteSiteCollection 扩展方法来删除网站集。
可以如下使用:
string userName = "admin@tenant.onmicrosoft.com";
string password = "password";
string siteUrl = "https://tenant-admin.sharepoint.com/";
using (ClientContext clientContext = new ClientContext(siteUrl))
{
SecureString securePassword = new SecureString();
foreach (char c in password.ToCharArray())
{
securePassword.AppendChar(c);
}
clientContext.AuthenticationMode = ClientAuthenticationMode.Default;
clientContext.Credentials = new SharePointOnlineCredentials(userName, securePassword);
var tenant = new Tenant(clientContext);
// use false, if you want to keep site collection in recycle bin
tenant.DeleteSiteCollection("https://tenant.sharepoint.com/sites/Test", true);
}
【讨论】:
使用全局管理员帐户连接到 SharePoint Online:
Connect-PnPOnline https://tenant-admin.sharepoint.com
通过 url 删除特定网站集:
Remove-PnPTenantSite -Url https://tenant.sharepoint.com/sites/sitename-Force -SkipRecycleBin
【讨论】: