As far as I know, if you want to delete top-level site, you need to delete site collection, and SharePoint 2013 on premise CSOM can't provide a method to achieve it.MySite is a top-level site,so you could not delete it with CSOM.
Test result:
More reference:
https://social.msdn.microsoft.com/Forums/SharePoint/en-US/bec41d45-56e7-4529-a5f8-f9b594842d36/cannot-delete-toplevel-site?forum=sharepointdevelopment
How to delete SharePoint On Premise MySite?
Will
616
Reputation points
Hi there,
Is it possible to remove (delete) particular personal site (SharePoint On Premise) by using CSOM?
Thanks
2 answers
Sort by: Most helpful
-
Amos Wu-MSFT 4,051 Reputation points
2020-08-14T07:11:28.88+00:00 -
Will 616 Reputation points
2020-09-14T08:25:28.14+00:00 Hi AmosWu,
I use the following code to delete my site:
SPWebApplication sPWebApplication = SPWebApplication.Lookup(new Uri(uriAddress));
SPFieldUrlValue _sp_Personal_Site_Location = new SPFieldUrlValue(properties.ListItem["sp_Personal_Site_Location"].ToString().Trim());sPWebApplication.Sites.Delete(_sp_Personal_Site_Location.Description);
sPWebApplication.Update();thanks