sharepoint - 如何以编程方式使用 pnp csom 删除 SharePoint 网站集
问题描述
我对 SharePoint Online Office 365 有一个要求。根据我的要求,我必须以编程方式使用 pnp csom 从 SharePoint Online Office 365 管理中心删除所有网站集。
任何人都可以建议我如何删除所有网站集?
解决方案
您可以使用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);
}
推荐阅读
- android - ViewPager 内的水平 RecyclerView 不滚动
- openmp - 使用 LLVM Clang 编译 NAS Parallel Benchmarks 会出错
- python-3.x - CNN-尝试使用 seaborn.heatmap 运行混淆矩阵
- c# - 在 IISIntegration 上运行 ASP.NET Core 应用程序时,Program.Main 会发生什么?
- c# - Azure 上缺少 mvc dll。怎么了?
- c - 找到一对数字的 4 次方等于输入数字
- javascript - 仅绘制 SVG 圆环图的底部
- linux - 需要有关 linux 中定期计时器的信息
- json - 解码包含转义双引号的字符串时,Json 解码器失败
- html - 对齐导航栏的问题