我对SharePoint Online Office 365有一个要求。根据我的要求,我必须以编程方式使用pnp csom从SharePoint Online Office 365管理中心删除所有网站集。
任何人都可以建议我如何删除所有网站集?
答案 0 :(得分:0)
使用全局管理员帐户连接到SharePoint Online:
Connect-PnPOnline https://tenant-admin.sharepoint.com
通过网址删除特定的网站集:
Remove-PnPTenantSite -Url https://tenant.sharepoint.com/sites/sitename-Force -SkipRecycleBin
答案 1 :(得分:0)
您可以使用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);
}