I'm trying to work out a process that would allow my helpdesk to delete an individual user's profile from Office 365 sharepoint online using powershell.
It's easy to connect to our Sharepoint Online URL and see the sites we have:
Connect-MsolService Connect-SPOService -url https://example-admin.sharepoint.com -Credential AccountWithOffice365AdminRights@example.com
I can verify that I'm connected.
get-sposite returns a list of our sharepoint online URLs, as you expect.
Running commands such as
remove-sposite work for the entire site collection, e.g.
repair-sposite -identity https://example-my.sharepoint.com works on the whole site collection, so the last thing I want to be doing is running
remove-sposite at this level, and running it at a deeper level (
repair-sposite -identity https://example-my.sharepoint.com/personal/user_example_com) fails to locate a sharepoint site to work with.
There are a few sites out there that have all cut and pasted the same snippet of code to iterate all the users in a sharepoint mysites collection and remove all of them, but I'm not convinced that code works for sharepoint 2013 sites and it's trivial to remove a user's permissions from a site. But I don't want to do either of those things, I just want to remove one user's profile from mysites.