I want to delete my sites without affecting existing user profiles and also want to disable my sites creation. I know to delete site collections using powershell script but want to know, is there a way to delete all my sites without affecting the my sites auto deletion setting.


You can delete just mysite, it will not impacting the user profiles. One thing you have to keep in mind that root url aka Mysite host should not be deleted.

You can also disable the mysite creation, it will not impact as well to the profiles. You can disbale either remove permission for all users from UPA and also disable the Auto provisioning of Mysite.

Lastly, disable the mysite auto deletion timer job

here is script which will delete all mysites in farm ( but please test it in test farm)

#Add SharePoint PowerShell SnapIn if not already added
 if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) {
    Add-PSSnapin "Microsoft.SharePoint.PowerShell"

$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)

       write-host $AccountName , " personel site deleted successfully"

Sharepoint 2010 – Delete all users’ personel sites via powershell

| improve this answer | |
  • thanks for the quick reply, let me test and confirm – Sivanrv Jun 3 at 2:49

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.