使用Powershell从Office 365 / Sharepoint Online MySite中删除个人用户configuration文件

我正在尝试制定一个stream程,允许我的帮助台使用PowerShell在线删除Office 365 SharePoint中的个人用户configuration文件。

连接到我们的Sharepoint在线URL并查看我们的网站很容易:

Connect-MsolService Connect-SPOService -url https://example-admin.sharepoint.com -Credential [email protected] 

我可以确认我已经连线。 按照您的预期, get-sposite返回我们的SharePoint在线URL的列表。

运行诸如repair-spositeremove-sposite命令为整个网站集合运行,例如repair-sposite -identity https://example-my.sharepoint.com在整个网站集合上运行,所以我想要在此级别运行remove-sposite ,并在更深层次上运行( repair-sposite -identity https://example-my.sharepoint.com/personal/user_example_com )无法find要使用的SharePoint站点。

有几个网站都有剪切和粘贴相同的代码片段迭代所有的用户在一个SharePoint的mysites集合,并删除所有这些,但我不相信代码适用于SharePoint 2013站点,这是微不足道的从网站中删除用户的权限。 但我不想做这些事情之一,我只想从mysites中删除一个用户的个人资料。

我一直在生成一个用于在线共享点的库,所以我最近一直在编写数百个这样的小任务,但基本上你需要使用CSOM命令。 首先,下载SharePoint Server 2013客户端上下文SDK。 然后确保你的代码中包含了DLL:

导入模块'C:\ Program Files \ Common Files \ Microsoft Shared \ Web服务器扩展\ 16 \ ISAPI \ Microsoft.SharePoint.Client.dll'

您的DLL的path可能不同于我的。

现在你可以使用CSOM来做你想做的任何事情。

这里有一些代码应该能够完成你正在做的事情。

 Import-Module 'C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll' #Needed for CSOM $SPOUsername="[email protected]" $SPOPassword="my plain text password" $SPCred=New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($SPOUsername,(ConvertTo-SecureString $SPOPassword -AsPlainText -Force)) $context = New-Object Microsoft.SharePoint.Client.ClientContext("https://Blah.sharepoint.com/sites/.....") $context.Credentials = $SPCred $web=$context.Web $context.Load($web.SiteUsers) $context.ExecuteQuery() $Web.SiteUsers|Select ID,Email,title #Display users and their IDs $Web.SiteUsers.RemoveById(<ID of target user>) $context.ExecuteQuery() 

我可以为你find最好的:

http://jopx.blogspot.com/2013/08/managing-sharepoint-online-with.html

其中说:

没有可用于pipe理SharePoint对象的网站集的较低范围的cmdlet。

但是,然后给这个可能性:

然而,使用SharePoint Server 2013客户端组件SDK(可启用针对SharePoint Server 2013的远程开发)在较低级别处理SharePoint Online中的对象时有一种解决方法。

但是,提供一个简单的PS脚本,以帮助台使用后,你不是。 你可能会考虑打开O365的支持票,但我的经验已经打了或小姐。 有时候,我看到有人只知道脚本的答案,然后有时候看起来我真的得到了实际的开发者。