6

Is there a easy way to remove (delete) all personal sites and recreate them all over again? I also want to delete them from the sql.

I've tried to delete personal sites and run my site clean up job but it seems not to be removed from the DB. I know I have to wait ~14 days and then ~11 days before they get removed from the DB. Is there a way to force delete them without waiting?

The reason I want to delte the db entry is to not get in a situation that the db runs out of space.

The best way would be to recreate the entire web application but I can't do that because of integration to all other systems.

When deleting personal mysites I run this lines..

..
foreach($profile in $AllProfiles)
{
    $DisplayName = $profile.DisplayName
    $AccountName = $profile[[Microsoft.Office.Server.UserProfiles.PropertyConstants]::AccountName].Value  

    if($profile.PersonalSite -ne $Null)
    {
       $profile.PersonalSite.Delete()
       write-host $AccountName , " personel site deleted successfully" -ForegroundColor Green
    }
}
  • The thread you refers to do not force delete them from the db, without waiting ~25 days – Plexus81 Jan 4 '16 at 9:41
  • 1
    Why not just compile a list of MySites based on managed path and/or Site Template ID (MYSITE#0, IIRC)? From there, use Remove-SPSite w/o -GradualDelete. You can then go through the UPM OM to clear out the Personal Site URL. – Trevor Seward Jan 4 '16 at 15:33
  • @TrevorSeward I did almost the same .. and it worked ok. – Plexus81 Jan 12 '16 at 14:43
0

Can you try with the below PS code for deleting the mysites?

 Add-PSSnapin "Microsoft.SharePoint.PowerShell"

 [Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server")
 $mysiteHostUrl = "http://my"
 $mysite = Get-SPSite $mysiteHostUrl
 $context = [Microsoft.Office.Server.ServerContext]::GetContext($mysite)
 $upm =  New-Object    
 Microsoft.Office.Server.UserProfiles.UserProfileManager($context)
 $AllProfiles = $upm.GetEnumerator()
 foreach($profile in $AllProfiles)
 {
 $DisplayName = $profile.DisplayName
  $AccountName = 
      $profile[[Microsoft.Office.Server.UserProfiles.
        PropertyConstants]::AccountName].Value  
  if($profile.PersonalSite -ne $Null)
   {
   $profile.PersonalSite.Delete()
   write-host $AccountName , " personal site deleted successfully"
    }
  }
  $mysite.Dispose();
  • I've got almost the same code .. but this code does not delete the personal site from the db straight away.. you have to wait ~25 days before sharepoint removes the personal site entry from the db – Plexus81 Jan 4 '16 at 9:47
  • Manipulating the entry directly from content db is not supported by MSFT. But can you look at the All_Docs table from your web app's content DB with your SS Mgmnt Studio? I hope you would be able to get the row in that table related to mysite. – userAZLogicApps Jan 4 '16 at 10:46
  • Can you check this link also: sharepoint-community.net/profiles/blogs/deleting-orphan-mysites – userAZLogicApps Jan 4 '16 at 10:52
  • Through SSMS : demantprasad.com/2013/09/… "select count(*) as 'Total Site Collection' from sites" . The below sql can get the web title and you would be able to get the mysite title and delete it from Content DB . "select Title as 'Root Web Title', Sites.RootWebId, Sites.Id as 'Site Collection ID' from webs inner join Sites on Webs.Id = Sites.RootWebId" . Hope this helps – userAZLogicApps Jan 4 '16 at 11:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.