I have created a community site, but some members of the community have created personal sites, which I do not want at this stage. But I am as the site administrator, I am unable to find a way to delete their personal sites, which include a blog, their personal photos, etc. can anyone advice please. Thanks
2 Answers
Refer the following links,
To delete using powershell, use the following code
#PowerShell Script - Delete All Users Personel Sites - SharePoint 2010
#The scripts is distributet "as-is." Use it on your own risk. The author give no warranties, guarantees or conditions.
#Add SharePoint PowerShell SnapIn if not already added
if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) {
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 , " personel site deleted successfully"
}
}
$mysite.Dispose();
Hope this might help you.
-
If you feel my above answer is correct, please mark it as answer, so that it would help others too. Sep 26, 2013 at 11:55
-
ok i was able to delete the personal site. but on my community site collection, if i click on a member name, i am still redirected to this URL.. Sep 26, 2013 at 12:20
-
This usually happens when mysites are configured improperly. Userdisp.aspx tries to redirect to the personal site if it has reason to believe that one exists. Go to central admin and in the user profile service application, ensure that the mysite settings are applied correctly. Sep 26, 2013 at 12:32
-
@KarthikJaganathan give me time to test it on my sp online Jan 7, 2014 at 21:48
the code above didn't work for me directly (SP2013) because for some reason the Users "PersonalSite"-Attribute was not filled, so I modified the foreach loop as follows (a bit crude, but you get the idea):
foreach($profile in $AllProfiles)
{
$DisplayName = $profile.DisplayName
Remove-SPSite -Identity $profile.UrlToCreatePersonalSite -GradualDelete -Confirm:$false
write-host $DisplayName , " personal site deleted successfully"
}
HTH