【问题标题】:How to delete SharePoint Site Collection using pnp csom programmatically如何以编程方式使用 pnp csom 删除 SharePoint 网站集
【发布时间】:2019-09-07 09:12:06
【问题描述】:

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

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

【问题讨论】:

    标签: sharepoint csom


    【解决方案1】:

    您可以使用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);
    
    }
    

    【讨论】:

      【解决方案2】:

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

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

      通过 url 删除特定网站集:

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

      Remove-PnPTenantSite

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-06-22
        • 1970-01-01
        • 2014-04-05
        • 2018-10-16
        • 2018-07-02
        • 1970-01-01
        • 1970-01-01
        • 2020-05-25
        相关资源
        最近更新 更多