如何以编程方式使用pnp csom删除SharePoint网站集

问题描述 投票:0回答:2

我对SharePoint Online Office 365有要求。根据我的要求,我必须使用pnp csom以编程方式从SharePoint Online Office 365管理中心删除所有网站集。

任何人都可以建议我如何删除所有网站集?

sharepoint csom
2个回答
0
投票

使用全局管理员帐户连接到SharePoint Online:

Connect-PnPOnline https://tenant-admin.sharepoint.com

按网址删除特定网站集:

Remove-PnPTenantSite -Url   https://tenant.sharepoint.com/sites/sitename-Force -SkipRecycleBin

Remove-PnPTenantSite


0
投票

您可以使用DeleteSiteCollection扩展方法删除网站集。

它可以用如下:

string userName = "[email protected]";
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);

}
© www.soinside.com 2019 - 2024. All rights reserved.